db.getCollection('users').aggregate([
    {$match:{ZWBH:11}},
    {$unwind:'$UUID'},
    {$project : { PM : { $split: ["$UUID.name", " "] } } },
    {$project: {PM:{ $arrayElemAt: [ "$PM", 0 ]}}},
    {$project: {PM:{ $toLower: "$PM"}}},
    {$group:{_id:'$PM',sum:{$sum:1}}},
     {$sort:{sum:-1}}
])

分组用户所用的手机品牌数量,其中UUID的格式是:

"UUID" : [ 
        {
            "id" : "xxxxxx",
            "name" : "HUAWEI DUK-AL20"
        }
    ],

 

相关文章:

  • 2022-01-14
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2021-12-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2022-02-25
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
相关资源
相似解决方案