SQL Quest › SQL Interview Questions › Joins
Avg DEED Amount Per Borough
Compute the average DEED amount per borough. JOIN sales with sales_legals to get per-borough averages. Show borough_code, deed_count, avg_amount, max_amount. Order by avg_amount descending. (sales.recorded_borough is the numeric code: 1=MN, 2=BX, 3=BK, 4=QN, 5=SI.)
Solve it in the browser editor →
Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".
Schema
sales
| document_id | record_type | doc_type | recorded_borough | document_date | document_amt | recorded_datetime |
|---|---|---|---|---|---|---|
| 2025081800333001 | A | DEED | 1 | 2025-08-14 | 1080000000 | 2025-08-18 |
| 2024012300948001 | A | DEED | 1 | 2024-01-22 | 963000000 | 2024-01-24 |
| 2025081800439001 | A | DEED | 1 | 2025-08-14 | 810000000 | 2025-08-20 |
sales_legals
| document_id | bbl | property_type | street_number | street_name | unit |
|---|---|---|---|---|---|
| 2026030200174005 | 2059330225 | CR | 5921 | PALISADE AVENUE | NULL |
| 2026031100344013 | 3024141401 | OT | 280 | KENT AVENUE | NRU |
| 2026030200423005 | 3043930001 | AP | 180 | WORTMAN AVENUE | NULL |
Expected output: Manhattan vs Brooklyn deal sizes
Hint
Concepts
SELECT JOIN GROUP BY Aggregation JOIN + GROUP BY
Practise the topic: SQL practice questions · JOIN practice · GROUP BY exercises
Related questions
Where would this cost you points in an interview?
Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.
Take the readiness test