Query to find every Nth record from a collection?

1,028 views
Skip to first unread message

Sumanth

unread,
Jan 20, 2011, 7:23:37 PM1/20/11
to mongodb-user
Hi
I have a collection that stores historical data every 1 hour(ex:
login count) .
I have to draw a chart that only show daily values for a given month.
Is it possible to query records that are 24 hours apart, skipping the
intermediate records ?
ie: Query to find every Nth row from a collection.

Thanks
Sumanth

PS: RDBMS has a solution.
http://geekexplains.blogspot.com/2008/06/sql-query-to-find-every-nth-row-from.html
I need a solution for Mongodb.

Keith Branton

unread,
Jan 20, 2011, 7:50:40 PM1/20/11
to mongod...@googlegroups.com
Easiest would be if http://jira.mongodb.org/browse/SERVER-465 was implemented already.

In the meantime you could just add an hour column to your documents, and query on that.


Reply all
Reply to author
Forward
0 new messages