Skip to content

Instantly share code, notes, and snippets.

@kurorido
Created July 2, 2015 07:56
Show Gist options
  • Select an option

  • Save kurorido/7e8ac6a50773243227f4 to your computer and use it in GitHub Desktop.

Select an option

Save kurorido/7e8ac6a50773243227f4 to your computer and use it in GitHub Desktop.
Mongo Aggregation
db.Zhengzhou.aggregate([
{ $match: { ModifiedTime: { $gt: ISODate("2015-07-01T00:00:00.000Z"), $lt: ISODate("2015-07-02T00:00:00.000Z")}, DeviceResponseTime: { $ne : 0 } } },
{
$project: {
date : { $dateToString : { format: "%Y-%m-%d", date: "$ModifiedTime" }},
DeviceResponseTime: 1
}
},
{
$group: {
_id: "$date",
avg: { $avg : "$DeviceResponseTime" },
count: { $sum: 1 }
}
}
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment