Your question is SQL KPI Pivot Report. 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.
Datavant Link operations needs a monthly report showing several linkage KPIs in a pivot-style result, with one row per organization and month.
Write a PostgreSQL query that reports production Datavant Link runs from January 1 through March 31, 2025. Use conditional aggregation to place multiple KPIs in separate columns.
Unknown.| Column | Type | Description |
|---|---|---|
| organization_idPK | INTEGER | Unique organization identifier |
| organization_name | VARCHAR(100) | Organization display name |
| Column | Type | Description |
|---|---|---|
| run_idPK | INTEGER | Unique linkage run identifier |
| organization_id | INTEGER | Organization associated with the run |
| started_at | TIMESTAMP | Time at which the run started |
| completed_at | TIMESTAMP | Time at which the run completed |
| run_status | VARCHAR(20) | Current run status |
| environment | VARCHAR(20) | Execution environment |
| input_records | INTEGER | Number of records submitted |
| matched_records | INTEGER | Number of records successfully matched |