任何人都可以帮我解决下面写的查询如何转换成mongodb:
Select KeyID, SUM(Qty) from Table where Date <= '1998-12-01'
(日期格式为YY-MM-DD)
答案 0 :(得分:44)
你想要像
这样的东西 db.myTable.aggregate( [
{ $match: { mydate: { $lte: new Date( '12/01/1998' ) } } },
{ $group: { _id: "$keyid",
totalqty: { $sum: "$qty" } } }
] )
此致
凯
答案 1 :(得分:0)
db.schoolexamregistration.aggregate([
{ $match: {"exam_session_id":"1523850138707"} },{
$lookup:
{
from: "student",
localField: "nic_ppt",
foreignField: "nic_ppt",
as: "student_detail"
}
} ])