Skip to content

Instantly share code, notes, and snippets.

@parkerfoshay
Created December 6, 2022 22:18
Show Gist options
  • Save parkerfoshay/76248f9c7ab432eb260070b65718e3c4 to your computer and use it in GitHub Desktop.
Save parkerfoshay/76248f9c7ab432eb260070b65718e3c4 to your computer and use it in GitHub Desktop.
between order by and limit
db.zips.find(
{ state: "NY", pop: { $gte: 1000, $lte: 5000 }},
{_id: 0, state: 1, city: 1, pop: 1}
).sort({pop: -1})
.limit(10)
SELECT city, state, pop
FROM zips
WHERE state = 'NY' AND pop BETWEEN 1000 AND 5000
ORDER BY pop DESC
LIMIT 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment