Tom Vo
unread,Sep 12, 2012, 6:19:37 AM9/12/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongod...@googlegroups.com
Dear all
My collections which have key is a array object.
I need sum total as SQL statement:
Select Line_Items.Name , Sum(Line_Items.Quantity) from Orders group by Line_Items.Name
Could I use group to sum data instead of map/reduce?
Please help me for this case ?
Thanks
My data samples
db.Orders.find()
{
"_id" : ObjectId("505057cbe415556238661561"),
"BuyerName" : "Lukas",
"Line_Items" : [
{
"Name" : "2012 Accord SeDan",
"Pricing" : 20,
"Quantity" : 1
},
{
"ProductID" : ObjectId("50504b36e41555623866155c"),
"Name" : "2012 Accord Coupe",
"Pricing" : 15,
"Quantity" : 2
}
],
"IssueDate" : ISODate("2012-03-08T00:00:00Z"),
"Total" : 50
}
,
{
"_id" : ObjectId("505057cbe415556238661560"),
"BuyerName" : "Bobby",
"Line_Items" : [
{
"Name" : "2012 Accord SeDan",
"Pricing" : 15,
"Quantity" : 1
}
],
"IssueDate" : ISODate("2012-02-08T00:00:00Z"),
"Total" : 15
}
Thanks and Regards.
Tom Vo