1
我有一個進料收集與樣數據的總和:在春天的MongoDB組一列,並得到另外兩個領域
{
"_id" : ObjectId("55deb33dcb9be727e8356289"),
"userName" : "John",
"likeCount" : 2,
"commentCount" : 10,
}
,
{
"_id" : ObjectId("55deb33dcb3456e33434d456"),
"channelName" : "Mark",
"likeCount" : 5,
"commentCount" : 10,
},
{
"_id" : ObjectId("55acd3434324acd3e4567567"),
"userName" : "John",
"likeCount" : 12,
"commentCount" : 15,
}
我想通過「username」的獲得所有組的記錄和總和「likeCount」+「commentCout」。 在MySQL中,我們使用:
select userName,sum(likeCount)+sum(commentCount) as "totalCount" from feed group by userName
我怎麼能寫上面的查詢聚集?
感謝chridam ...您幫忙 – Pankaj
不用擔心@Pankaj :-) – chridam