Hi all,
I am trying to make a sum of two count results, that is my query:
[
{ "$facet": {
"Total": [
{ "$match" : { "status": { "$eq": "approved" }}},
{ "$count": "Total" }
],
"Approved": [
{ "$match" : {"status": { "$eq": "pending" }}},
{ "$count": "Approved" }
]
}},
{"$addFields":{"overall":{ "$sum": ["$Total", "$Approved"]}}},
{ "$project": {
"Total": { "$arrayElemAt": ["$Total.Total", 0] },
"Approved": { "$arrayElemAt": ["$Approved.Approved", 0] },
"overall":"$overall"
}}
]
and I get these answer:
There are no error message but overall as sum of 2 count equals 0
Can anyone help me with this problem?