Your question is SQL Running Total and Rank. 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.
Enverus Prism analysts need a basin-level view of active well performance. Write a PostgreSQL query that aggregates 2024 oil production, ranks wells within each basin, and calculates a running basin total.
active and whose basin is not null.production_monthly for calendar year 2024, retaining active wells with no matching production.well_id.| Column | Type | Description |
|---|---|---|
| well_idPK | INTEGER | Unique well identifier |
| well_name | VARCHAR(100) | Well name |
| basin | VARCHAR(50) | Production basin |
| operator | VARCHAR(100) | Operating company |
| status | VARCHAR(20) | Current well status |
| Column | Type | Description |
|---|---|---|
| production_idPK | INTEGER | Unique production record identifier |
| well_id | INTEGER | Referenced well identifier |
| production_month | DATE | Month represented by the production record |
| oil_bbl | INTEGER | Monthly oil production in barrels |