3 回答
阿波罗的战车
TA贡献1862条经验 获得超6个赞
参考代码:
var pipeline =[
{
$match: {
sjbh: {$gte: beginDate, $lte:endDate}
}
},
{
$group: {
_id: "$gsbh",
totaltxl: {$sum: { $cond: { if: { $ne: [ "$totalnum","" ] }, then:"$txl" , else: 0 }}},
totalbmynum: {$sum: "$bmynum"}
}
},
{
$project: {
_id: 0,
gsbh: "$_id",
totaltxl: "$totaltxl",
totalbmynum: "$totalbmynum",
ratio: { $divide: [ "$totalbmynum", { $cond:{if: { $eq: [ "$totaltxl",0 ] }, then:1 , else: "$totaltxl" }}] }
}
},
{$sort: {ratio: -1}},
{$limit: 5}
{$skip : 5}
]
opts.dbs.csdb.collection("permydfx").aggregate(pipeline).......
- 3 回答
- 0 关注
- 656 浏览
添加回答
举报
0/150
提交
取消