SQL QuestSQL Interview Questions › Joins

Property Sale + Buyer

MediumFreeQuerying BasicsJoins

For Manhattan DEED documents above $5M: show bbl, address (from properties), document_amt, buyer_name. Triple JOIN: sales → sales_legals → properties, plus sales → sales_parties (filtered to BUYER). Order by document_amt descending. Top 10.

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

properties

bblboroughaddresszipbldg_classland_useyear_builtnum_floorsunits_residentialunits_totallot_area_sqftbldg_area_sqftassess_totalowner_namelatitudelongitude
1009720001MN240 1 AVENUE10009D74194513.00000008764881226750008942176790924050.00000BPP ST OWNER LLC40.7317236-73.9778964
1009950005MN1472 BROADWAY10036O45199851.000000002458001642675489648150.00000NYC ECONOMIC DEVELOPMENT CORPORATION40.7560214-73.9857642
1010070029MN1345 AVENUE OF THE AMER10105O95196849.0000000050903751931978429758550.000001345 LEASEHOLD LLC40.7630634-73.9792541

sales_parties

document_idparty_typeparty_rolename
20260302001740051SELLERRIVER'S EDGE
20260302004230051SELLERSTANLEY AVENUE PRESERVATION HDFC
20260302004230052BUYERNEW YORK CITY HOUSING DEVELOPMENT CORPORATION

Expected output: Building + price + who bought it

Hint

Four-table JOIN. The buyer-side parties may have multiple rows per document (corporate ownership), so consider GROUP BY or a subquery.

Concepts

SELECT JOIN WHERE Multi-JOIN

Practise the topic: SQL practice questions · JOIN practice

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