Your question is Top 3 Revenue by Region. 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.
Newton School of Technology wants a regional revenue summary for its course enrollments. Write a PostgreSQL query that calculates the sum of the three highest valid order revenues within each region.
orders with regions using region_id.revenue descending. Break revenue ties with the smaller order_id.NULL revenue, keep only the top three orders per region, and return the regional sum.| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Primary key for a Newton School operating region |
| region_name | VARCHAR(50) | Name of the operating region |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Primary key for an enrollment order |
| region_id | INT | Region associated with the order |
| revenue | DECIMAL(12,2) | Revenue generated by the order |