您好,登录后才能下订单哦!
mongodb数据如下:
db.cpc_0103.find()
{ "a" : 8, "b" : "108177_200701010000", "c" : 108177, "d" : 180, "e" : 1404917, "f" : "U盘", "g" : 184543, "h" : "U盘网上批发市场", "i" : 90, "j" : 3, "k" : 3, "l" : "", "m" : "2007-01-01 00:00:00", "n" : "", "o" : "", "p" : -1, "q" : "--", "r" : 0, "s" : "" }
......
......
如何对其中的一列数据SUM,
xreport-cpc:PRIMARY> var reduce = function(key, values){
... ... var count=0;
... ... values.forEach(function(v) {
... ... count+=v.p;
... ... });
... ... return {count: count};
... ... };
xreport-cpc:PRIMARY> var reduce = function(key, values){
... var count=0;
... values.forEach(function(v) {
... count+=v.cm;
... });
... return {count: count};
... };
xreport-cpc:PRIMARY> var s = db.c.find();
xreport-cpc:PRIMARY> var s = db.test.find();
xreport-cpc:PRIMARY> reduce("total_cm", s);
执行结果如下:
{ "count" : 20328860 }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。