复制PostgreSQL的窗口函数,例如滞后,超前,结束 [英] Duplicating PostgreSQL's window functions like lag, lead, over

查看:86
本文介绍了复制PostgreSQL的窗口函数,例如滞后,超前,结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将PostgreSQL查询更改为mongodb bson调用?我在 http://archives.postgresql中列出了相同的用例.org/pgsql-general/2011-10/msg00157.php 我想通过使用滞后或提前量来计算两个日志条目之间的时间差.mongodb中有什么类似于Postgres的lag/lead语法?

How do I change a PostgreSQL query into a mongodb bson call? I have the same use case listed at http://archives.postgresql.org/pgsql-general/2011-10/msg00157.php I would like to calculate the delta time between two log entries by using something like lag or lead. Is there anything similar in mongodb to Postgres' lag / lead syntax?

select 
  index, 
  starttime, 
  endtime, 
  starttime - lag(endtime) over(order by starttime asc) as delta 
from test

http://www.postgresql.org/docs/8.4/static/functions-window.html

我正在查看 http://www.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/,看来 map / reduce /完成即可. Map id,开始时间和结束时间, reduce 不执行任何操作,然后在执行过程中对其自身(两个 for s)进行内部联接.完成.我几乎可以看到它……

I was looking at http://www.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/ and it seems that map / reduce / finalize should do it. Map the id, start and end time, reduce does nothing, then do a inner join on its self (the double fors) during the finalize. I can almost, kind of, sort of, see it...

推荐答案

这是您在应用程序中必须要做的事情.目前,mongoDB不支持任何此类功能.

This is something you'll have to do in your application. Right now, mongoDB doesn't support anything like this.

这篇关于复制PostgreSQL的窗口函数,例如滞后,超前,结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆