A retail analytics team needs a calendar-year revenue report by product category. Write a PostgreSQL query that calculates category revenue and the number of distinct orders contributing to that revenue for the anchored calendar year 2026. Include only categories whose total revenue exceeds 5,000.
category_name, total_revenue, and order_countquantity * price_per_unit; rows with a NULL quantity or price are ignored by the aggregatetotal_revenue descending, then category_name ascending| Column | Type | Description |
|---|---|---|
| category_idPK | INT | Primary key for a product category |
| category_name | VARCHAR(100) | Product category name |
| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Primary key for a product |
| product_name | VARCHAR(150) | Product name |
| category_id | INT | Category containing the product |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Primary key for an order |
| order_date | DATE | Date on which the order was placed |
| Column | Type | Description |
|---|---|---|
| order_item_idPK | INT | Primary key for an order line |
| order_id | INT | Order containing the line item |
| product_id | INT | Product sold on the line |
| quantity | INT | Number of units sold |
| price_per_unit | NUMERIC(12,2) | Unit selling price |