我想在某些日期之间对MongoDB中不同的值进行计数。如何在MongoDB中统计不同的值?
喜欢的东西在SQL如下:
select distinct(count(iid))
from collection
Where date > 2015-04-03 and date < 2015-04-04
我已经成功地运行在MongoDB的下面的查询,但是,这种返回总数(不重复值的计数):
db.m_2015_04.find(
{ "_timestamp" : { "$gte" : ISODate("2015-04-03T00:00:000Z"), "$lt" : ISODate("2015-04-03T23:59:000Z") }})
.count()
不幸的是,这个结果有错误。 – 2015-04-06 13:56:55