Nightly Price Leaderboard
Return listing_id, city, and price_per_night for all listings ordered by price_per_night descending, then listing_id.
- Sorting
Challenge brief
Understand the request
Supply — Market Intelligence The supply team uses the price leaderboard to benchmark new listings and guide hosts on competitive pricing.
Rank all listings from most to least expensive per night.
Return
- listing_id
- city
- price_per_night
Constraints
- Include every listing
- Order by nightly price descending, then listing ID
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
listings
listing_idINTEGERcityVARCHAR(50)price_per_nightINTEGER
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
Nightly price is a listing attribute.
Hint 2
Sort the highest price first.
Hint 3
Use listing ID to resolve equal prices.
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT listing_id, city, price_per_night FROM listings ORDER BY price_per_night DESC, listing_idWhy this works
A simple single-table SELECT from listings ordered by price descending. No filter or JOIN needed — the output is the complete price ranking.
Success check
Returns the complete catalog in a deterministic price ranking
Expected result
Use this output to verify values, aliases, ordering, and row count.
| listing_id | city | price_per_night |
|---|---|---|
| 5 | San Francisco | 200 |
| 3 | London | 180 |
| 6 | Paris | 160 |
| 1 | New York | 150 |
| 7 | Lisbon | 150 |
| 4 | Toronto | 140 |
| 2 | Bangalore | 60 |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Explore related company challenges
Uber
Independent Uber-style mobility marketplace SQL practice covering trips, drivers, riders, pricing, payments, and promotions.
Amazon
Independent Amazon-style e-commerce, warehouse, inventory, and customer analytics SQL practice.
Meta
Independent Meta-style social-product, engagement, content, community, messaging, and advertising SQL practice.
Return to the complete interview preparation experience.