SQL QuestSQL Interview Questions › Joins

Avg DEED Amount Per Borough

MediumFreeQuerying BasicsJoinsAggregation & Grouping

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_idrecord_typedoc_typerecorded_boroughdocument_datedocument_amtrecorded_datetime
2025081800333001ADEED12025-08-1410800000002025-08-18
2024012300948001ADEED12024-01-229630000002024-01-24
2025081800439001ADEED12025-08-148100000002025-08-20

sales_legals

document_idbblproperty_typestreet_numberstreet_nameunit
20260302001740052059330225CR5921PALISADE AVENUENULL
20260311003440133024141401OT280KENT AVENUENRU
20260302004230053043930001AP180WORTMAN AVENUENULL

Expected output: Manhattan vs Brooklyn deal sizes

Hint

GROUP BY recorded_borough (sales) HAVING doc_type='DEED'. Use AVG, MAX, COUNT.

Concepts

SELECT JOIN GROUP BY Aggregation JOIN + GROUP BY

Practise the topic: SQL practice questions · JOIN practice · GROUP BY exercises

Related questions

Customers Who Never OrderedMedium · FreeAbove-Average Departments (Derived Table)Medium · FreeLEFT JOIN NULL Semantics: Inactive CustomersMedium · FreeManagement Hierarchy OverviewMedium · FreeCount Direct ReportsMedium · FreeCustomer Recency AnalysisMedium · Free

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