Your question is Top Procedures by State. Start with the requirements and the four 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.
Gainwell Technologies needs a quarterly view of medical procedure utilization across state Medicaid programs. Analysts must identify the procedures most frequently billed in each provider state.
Assume the reporting date is August 29, 2026, so the last completed calendar quarter is April 1 through June 30, 2026. Write a PostgreSQL query that returns the top three billed procedures per state.
billing_status = 'BILLED' during the last completed quarter.| Column | Type | Description |
|---|---|---|
| provider_idPK | INT | Unique provider identifier |
| provider_name | VARCHAR(150) | Provider or organization name |
| state_code | VARCHAR(2) | Two-character provider state code |
| taxonomy | VARCHAR(100) | Provider specialty classification |
| Column | Type | Description |
|---|---|---|
| claim_idPK | INT | Unique claim identifier |
| claim_number | VARCHAR(30) | External claim reference |
| provider_id | INT | References providers.provider_id |
| member_id | VARCHAR(30) | Medicaid member identifier |
| service_date | DATE | Date services were provided |
| claim_status | VARCHAR(20) | Overall claim processing status |
| Column | Type | Description |
|---|---|---|
| claim_line_idPK | INT | Unique claim line identifier |
| claim_id | INT | References claims.claim_id |
| procedure_id | INT | References medical_procedures.procedure_id |
| billing_status | VARCHAR(20) | Line billing disposition |
| units | INT | Number of units billed |
| Column | Type | Description |
|---|---|---|
| procedure_idPK | INT | Unique procedure identifier |
| procedure_code | VARCHAR(10) | Procedure billing code |
| procedure_name | VARCHAR(150) | Procedure description |