【问题标题】:Need to convert this into MongoDB form [closed]需要将其转换为 MongoDB 形式 [关闭]
【发布时间】:2020-11-20 01:31:03
【问题描述】:
SELECT Country_Region, MAX(Confirmed), MAX(Deaths) 
FROM `covid_19` 
GROUP BY Country_Region 
ORDER BY `MAX(Confirmed)` DESC LIMIT 10

需要把这个转换成MongoDB形式

【问题讨论】:

  • 请发布您的数据

标签: sql mongodb


【解决方案1】:

这里是mongodb 的等效语法:

db.covid_19.aggregate( [
  {
    $group: {
       _id: "$Country_Region",
       MaxConfirmed: { $max: "$Confirmed" },
       MaxDeath: {$max: "$Deaths"}
    }
  }, { $sort:{"MaxConfirmed":-1}}
   , { $limit: 10 }
] )

【讨论】:

    猜你喜欢
    • 2013-10-05
    • 1970-01-01
    • 2012-08-12
    • 2022-01-05
    • 2020-09-23
    • 2011-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多