Your question is Top N Per Group Query. Start with the requirements and the one table 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.
CustomerInsights.AI needs one highest-performing insight record from each dashboard group. Write a PostgreSQL query that returns the top record per group_name, where performance is measured by metric_value.
group_name.metric_value; use the smallest record_id to break ties.| Column | Type | Description |
|---|---|---|
| record_idPK | INT | Unique insight record identifier |
| group_name | VARCHAR(100) | CustomerInsights.AI insight group |
| record_name | VARCHAR(150) | Name of the insight record |
| metric_value | DECIMAL(10,2) | Performance metric used for ranking |