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
![](https://secure.gravatar.com/avatar/f9a301aa04e25010dc82f0847db12a19?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)