How would you use SQL window functions to compare each property's transaction price to the previous sale in the same neighborhood?
Use the properties and transactions tables. Order sales chronologically within each neighborhood, using transaction_id to break ties. If there is no previous sale or the relevant price is NULL, the comparison should be NULL.
| Column | Type | Description |
|---|---|---|
| property_idPK | INT | Unique property identifier |
| address | VARCHAR(150) | Property street address |
| neighborhood | VARCHAR(80) | Neighborhood containing the property |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| property_id | INT | Property involved in the transaction |
| transaction_date | DATE | Date of the property transaction |
| transaction_price | NUMERIC(12,2) | Recorded transaction price |