MongoDB SELECT COUNT GROUP BY

后端 未结 7 2191
不知归路
不知归路 2020-11-22 15:24

I am playing around with MongoDB trying to figure out how to do a simple

SELECT province, COUNT(*) FROM contest GROUP BY province

But I can

相关标签:
7条回答
  • 2020-11-22 15:49

    Additionally if you need to restrict the grouping you can use:

    db.events.aggregate( 
        {$match: {province: "ON"}},
        {$group: {_id: "$date", number: {$sum: 1}}}  
    )
    
    0 讨论(0)
提交回复
热议问题