Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // to be executed on common.rateplans collection
- db.rateplans.aggregate([
- {$match: {"hotel_id":1}},
- {$group: {
- "_id": {
- "room_type": "$room_type"
- },
- "cnt": {$sum: 1}
- }},
- {$project: {
- "_id": 0,
- "room_type": "$_id.room_type",
- "rp_count": "$cnt"
- }},
- {$sort: {
- "rp_count": -1
- }}
- ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement