Your question is Top 3 Categories by Revenue. 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.
CCC Intelligent Solutions needs a revenue summary for completed transactions processed through CCC ONE. Write a PostgreSQL query that identifies the top three sales categories for calendar year 2025.
sales to sale_categories using category_id.status = 'Completed' and a sale_date in 2025.quantity * unit_price, treating NULL quantity or price as zero.| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique identifier for the sale |
| category_id | INT | References sale_categories.category_id |
| quantity | INT | Number of units sold |
| unit_price | NUMERIC(12,2) | Price for one unit |
| status | VARCHAR(20) | Current sale status |
| sale_date | DATE | Date on which the sale occurred |
| Column | Type | Description |
|---|---|---|
| category_idPK | INT | Unique identifier for a sales category |
| category_name | VARCHAR(50) | Name of the CCC ONE sales category |