mongodb求最大值

有个Collection ,就是表 ,stock_quotation

现在要查询最大的交易日期

db.stock_quotation.aggregate([{$group : {_id : null, max : {$max : "$trading_day"}}}]);
db.stock_quotation.aggregate([{$group : {_id : "stockno", max : {$max : "$trading_day"}}}]);

null所有的股票里面的最大值,加了stockno,分类里面最大

猜你喜欢

转载自my.oschina.net/hfq/blog/1816737