且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MongoDB相当于SQL COUNT GROUP BY

更新时间:2022-06-23 05:31:38

您首先 $ group _id:$ a $ sum:{1} (这基本上是你对不同a的计数) c $ c> sort 。

You first $group on _id:"$a" with $sum:{1} (this is basically your count on distinct a) then sort on the sum.