Your question is Top 3 Per Category SQL. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Cotality Property Insights needs a ranked view of active properties for market analysis. Write a PostgreSQL query that returns the top three properties by estimated market value within each active property category.
property_listings to property_categories using category_id.listing_id ascending.| Column | Type | Description |
|---|---|---|
| category_idPK | INT | Unique property category identifier |
| category_name | VARCHAR(100) | Display name of the property category |
| is_active | BOOLEAN | Whether the category is active in Cotality Property Insights |
| Column | Type | Description |
|---|---|---|
| listing_idPK | INT | Unique property listing identifier |
| category_id | INT | Referenced property category identifier |
| address | VARCHAR(200) | Property street address |
| estimated_market_value | NUMERIC(12,2) | Estimated market value of the property |
| valuation_date | DATE | Date on which the estimate was produced |
| listing_status | VARCHAR(30) | Current listing status |