1
我需要两天内输出性别,计数和更新时间的记录。在mongodb中使用UNIX时间戳Group By Hour
db.FaceData.aggregate([ {$match: { 'Timestamp' : { $gte : 1448121600000, $lt : 1448294399000 }, 'DID' : "ABFR001" }}, {$group: { _id: {'Gen': '$Gen'}, count : { $sum : 1 } }} ]);
output:
------
{ "_id" : { "Gen" : 1 }, "count" : 3055 }
{ "_id" : { "Gen" : 0 }, "count" : 2866 }
在上面的输出中,我必须按小时分组两天,例如,每小时我需要Gender,Count为2天。
时间戳以毫秒为单位。
感谢chridam,你的代码引导我找到了解决办法,我通过增强使用小时格式的上述代码 –
@SabareeshGunasekaran什么是解决方案?我有同样的问题 – DiegoRBaquero