{
"id" : "12345"
"energy" : "electricity",
"type" : "lighting",
"value" : 24324
},
{
"id" : "12345"
"energy" : "electricity",
"type" : "equipment",
"value" : 24324
},
{
"energy" : "electricity",
"type" : "fans",
"value" : 24324
},
{
"id" : "12345"
"energy" : "electricity",
"type" : "distribution",
"value" : 24324
},
{
"id" : "12345"
"energy" : "electricity",
"type" : "chiller",
"value" : 24324
},
{
"id" : "12345"
"energy" : "electricity",
"type" : "other",
"value" : 24324
}
This is my query to find total value. I use $project.
db.invoices.aggregate([
{
$project: {
total: {$sum : "$value"}
}
}])
I try to find the total value. Can any one please help to find the total value. also find the value with the Id wise.