Skip to main content

One post tagged with "java"

View All Tags

· One min read

DB search sql:

  1. 筛选出拥有 openId 的用户,对这些用户进行按年月日分组,并统计每天新增的用户数
db.user.aggregate(
[
{
$match: { "openId": { $exists: true } }
},
{
$group : {
_id : { month: { $month: "$createDate" }, day: { $dayOfMonth: "$createDate" }, year: { $year: "$createDate" } },
count: { $sum: 1 }
}
}
]
)