统计所有员工,并且他们在时间范围之间拥有mongodb 5000以上的工资

时间:2014-07-14 09:45:10

标签: mongodb mongoid

计算所有员工,并且在时间范围之间的mongodb中有超过5000的工资

UserStayedTime.collection.aggregate({"$match" => {"starttime"=> { "$gte" => start_date.to_time.utc.beginning_of_day},"endtime" => {"$lte" => end_date.to_time.utc.end_of_day}}}, "count1" => {'$salary' => {"$gte" => 5000 } } , "count"=>{ "$sum"=> 1} )

然后我收到错误,任何人都可以帮助我,谢谢

1 个答案:

答案 0 :(得分:0)

UserStayedTime.where("starttime" => { "$gte" => start_date.to_time.utc.beginning_of_day}, "endtime" => {"$lte" => end_date.to_time.utc.end_of_day}, "salary" => {"$gte" => 5000 }).count