Improve SQL Query
for the follow query :
select count(*)
from MEGA_CONTACT
where CivSelection = 2
I have this result in mongoshell
db.getCollection("MEGACONTACT").aggregate(
[
{
"$match" : {
"CivSelection" : NumberLong(2)
}
},
{
"$group" : {
"id" : {
},
"COUNT(*)" : {
"$sum" : NumberInt(1)
}
}
},
{
"$project" : {
"_id" : NumberInt(0),
"COUNT(*)" : "$COUNT(*)"
}
},
{
"$project" : {
"_id" : NumberInt(0),
"COUNT(*)" : "$COUNT(*)"
}
}
]
);
the second project is not utile no ?
1
vote
Eric Macarez
shared this idea