Your question is Second Highest Tier Revenue. Start with the requirements and the three 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.
Paramount+ analysts need to compare subscription-tier revenue across geographic markets. Write a PostgreSQL query that finds the second-highest revenue-generating tier within each region.
status = 'paid' and a non-null revenue value.Regions with fewer than two qualifying tiers should not appear in the result.
| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Unique geographic region identifier |
| region_name | VARCHAR(100) | Display name of the geographic region |
| Column | Type | Description |
|---|---|---|
| plan_idPK | INT | Unique Paramount+ plan identifier |
| tier_name | VARCHAR(50) | Name of the subscription tier |
| Column | Type | Description |
|---|---|---|
| subscription_idPK | INT | Unique billing record identifier |
| region_id | INT | Region associated with the subscription |
| plan_id | INT | Plan associated with the subscription |
| revenue | NUMERIC(10,2) | Revenue recorded for the billing record |
| status | VARCHAR(20) | Billing status, such as paid or pending |