Your question is Top Products by Sales 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.
Catalina uses product sales data to evaluate product performance across retail campaigns. Write a PostgreSQL query that identifies the three products with the highest sales revenue during the last 12 months.
Assume the query runs on 2026-08-29, so the reporting period begins on 2025-08-29. Include products with no qualifying sales in the intermediate calculation, but return only the top three products.
products to sales while preserving products that have no sales.CURRENT_DATE - INTERVAL '1 year' through CURRENT_DATE.| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| product_name | VARCHAR(100) | Product display name |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique sale identifier |
| product_id | INT | Product associated with the sale |
| sale_date | DATE | Date on which the sale occurred |
| sale_amount | NUMERIC(12,2) | Revenue attributed to the sale |