MongoDB分组查询数据库sql

db.test_col2.aggregate([
{
$group:{
_id: {
productName: “productName”,
brandName: “brandName”,
productCompanyName: “productCompanyName”,
categoryIdFullPath: “categoryIdFullPath”
},
total1:{sum: {toDouble:“stopTime”}},
total2:{sum: {toDouble:“clickCount”}}
}
}
])

通过productName,brandName,productCompanyName,categoryIdFullPath四个字段作为条件进行分组,对stopTime和clickCount分别进行求和

在做MongoDB的过程中曾经参考的博客地址:
https://www.jb51.net/article/128729.htm
https://www.cnblogs.com/duanxz/p/3600052.html
https://blog.csdn.net/ruoguan_jishou/article/details/79289369
https://www.jianshu.com/p/a576499769ae
https://www.jianshu.com/p/78b96ca40927
https://blog.csdn.net/C18298182575/article/details/100698885
https://blog.csdn.net/weixin_36181282/article/details/115855109?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_baidulandingword~default-0.pc_relevant_default&spm=1001.2101.3001.4242.1&utm_relevant_index=3
https://blog.csdn.net/qq_33695124/article/details/116225571
https://blog.csdn.net/qq_38359685/article/details/113865582?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2aggregatepagefirst_rank_ecpm_v1~rank_v31_ecpm-1-113865582.pc_agg_new_rank&utm_term=mongoTemplate+%E6%97%B6%E9%97%B4%E8%8C%83%E5%9B%B4%E6%9F%A5%E8%AF%A2&spm=1000.2123.3001.4430
https://blog.csdn.net/fysuccess/article/details/83689403
https://blog.csdn.net/weixin_34617955/article/details/112942529
https://blog.csdn.net/qq_33556185/article/details/53099085?locationNum=8&fps=1

你可能感兴趣的:(mongodb,sql,数据库)