Implement select group by in a big dataset.
Write a SQL query that returns one row per grouping key with the required aggregate metrics. The dataset is large, so the result should be correct and stable for duplicate, missing, and out-of-order rows.
| Column | Type | Description |
|---|---|---|
| record_idPK | BIGINT | Unique row identifier |
| grouping_key | VARCHAR(50) | Key used to group rows |
| metric_value | NUMERIC(12,2) | Numeric value to aggregate |
| is_active | BOOLEAN | Whether the row should be included |
| created_at | DATE | Row creation date |