翻译查询将max和min从mysql组合到mongoDB

时间:2016-01-16 13:28:56

标签: mysql sql mongodb

我的文件如下:

{
  "_id": ObjectId("5698fcb5585b2de0120eba31"),
  "id": "26125242313",
  "parent_id": "26125241841",
  "link_id": "10024080",
  "name": "26125242313",
  "author": "gigaquack",
  "body": "blogging = creative writing",
  "subreddit_id": "6",
  "subreddit": "reddit.com",
  "score": "27",
  "created_utc": "2007-10-22 18:39:31"
}

我正在使用mysql数据库。我使用这个查询:

Select max(score), author from (select sum(score) as score,
author as author from reddit where author in 
(select distinct author from reddit) group by author)
union
Select min(score), author from (select sum(score) as score, 
author as author from reddit where author in 
(select distinct author from reddit) group by author) 

现在我想将此查询翻译成mongoDB。我该怎么做? 对不起,问题不明确。我想要一个查询来计算用户的分数,并显示最大组合分数和最小组合分数与用户名。像:

 xxxx|150   yyyy|2 

0 个答案:

没有答案