Jangogo : 

可以的

Sql代码 
  1. 在sql中:select a,b,sum(c) csum from coll where active=1 group by a,b


在MongoDB中

  1. db.coll.group(   
  2.            {key: { a:true, b:true },   
  3.             cond: { active:1 },   
  4.             reduce: function(obj,prev) { prev.csum += obj.c; },   
  5.             initial: { csum: 0 }   
  6.             });   
  7. key: Fields to group by.   
  8. reduce: The reduce function aggregates (reduces) the objects iterated. Typical operations of a reduce function include summing and counting. reduce takes two arguments: the current document being iterated over and the aggregation counter object. In the example above, these arguments are named obj and prev.   
  9. initial: initial value of the aggregation counter object.   
  10. cond: An optional condition that must be true for a row to be considered. This is essentially a find() query expression object. If null, the reduce function will run against all rows in the collection.  


详细的你可以看官网
javascript:lnkchk('noitagerggA%2fSCOD%2fyalpsid%2fgro.bdognom.www%2f%2f%3aptth');

Sql代码
  1. db.coll.group(
  2. {key: { a:true, b:true },
  3. cond: { active:1 },
  4. reduce: function(obj,prev) { prev.csum += obj.c; },
  5. initial: { csum: 0 }
  6. });
  7. key: Fields to group by.
  8. reduce: The reduce function aggregates (reduces) the objects iterated. Typical operations of a reduce function include summing and counting. reduce takes two arguments: the current document being iterated over and the aggregation counter object. In the example above, these arguments are named obj and prev.
  9. initial: initial value of the aggregation counter object.
  10. cond: An optional condition that must be true for a row to be considered. This is essentially a find() query expression object. If null, the reduce function will run against all rows in the collection.
文档中心
Copyright © 2000-2016 粤ICP05021785号
地址:广州市天河区员村二横路8号全丰商业大厦808室 邮编:510600