Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. // to be executed on common.rateplans collection
  2. db.rateplans.aggregate([
  3. {$match: {"hotel_id":1}},
  4. {$group: {
  5. "_id": {
  6. "room_type": "$room_type"
  7. },
  8. "cnt": {$sum: 1}
  9. }},
  10. {$project: {
  11. "_id": 0,
  12. "room_type": "$_id.room_type",
  13. "rp_count": "$cnt"
  14. }},
  15. {$sort: {
  16. "rp_count": -1
  17. }}
  18. ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement