Airbnb-style Company ChallengeEasyVerified answerSQLite live

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_idINTEGER
  • cityVARCHAR(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_id

Why 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_idcityprice_per_night
5San Francisco200
3London180
6Paris160
1New York150
7Lisbon150
4Toronto140
2Bangalore60

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Interview Practice

Return to the complete interview preparation experience.