Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { "_id" : { "borough" : "Manhattan", "cuisine" : "Tex-Mex" }, "RestaruntCount" : 53 }
- { "_id" : { "borough" : "Manhattan", "cuisine" : "Bakery" }, "RestaruntCount" : 221 }
- { "_id" : { "borough" : "Manhattan", "cuisine" : "Soups & Sandwiches" }, "RestaruntCount" : 44 }
- { "_id" : { "borough" : "Manhattan", "cuisine" : "Vietnamese/Cambodian/Malaysia" }, "RestaruntCount" : 38 }
- { "_id" : { "borough" : "Manhattan", "cuisine" : "Filipino" }, "RestaruntCount" : 5 }
- { "_id" : { "borough" : "Manhattan", "cuisine" : "Egyptian" }, "RestaruntCount" : 5 }
- { "_id" : { "borough" : "Manhattan", "cuisine" : "Nuts/Confectionary" }, "RestaruntCount" : 4 }
- db.restaurants.aggregate( [ { $match: { "borough": "Manhattan" } }, { $group: {_id: {borough:"$borough", cuisine: "$cuisine"}, count : { $sum : 1} } }, {$sort: {count:1,_id:1}} ] );
- db.restaurants.aggregate([
- {
- $match: { "_id.borough": "Manhattan" }
- },
- {
- $sort: { RestaruntCount: 1 }
- },
- {
- $group: {
- _id: null,
- first: { $first: "$$ROOT" },
- last: { $last: "$$ROOT" }
- }
- }
- ])
Add Comment
Please, Sign In to add comment