db.getCollection('tran_string_detail').aggregate(
[
{
$match : { "deleteFlag":0,
"charCount":{
$exists:false
} }
} ,


{
$group :
{
_id : "$projectId", count: { $sum: 1 }
}
}
,{$sort:{count:-1}}
]
)




db.getCollection('tran_string').aggregate(
[
{
$match : {
"fileId":548,
"deleteFlag":0,
"fileVersion":5,
"isValid":1

}
} ,


{
$group :
{
_id : "$fileId", count: { $sum: 1 }, totalAmount: {$sum:"$charCount"}
}
}
,{$sort:{count:-1}}
]
)