Can you describe a time when you optimized a slow-running query in SQL?
You are given a query that returns active Filevine matters with their latest activity timestamp. Write a SQL query that produces the same result set efficiently.
matter_id, matter_name, latest_activity_atstatus = 'active'latest_activity_at descending, then matter_id ascending| Column | Type | Description |
|---|---|---|
| matter_idPK | INT | Unique matter identifier |
| matter_name | VARCHAR(120) | Matter name |
| status | VARCHAR(20) | Matter status such as active or closed |
| Column | Type | Description |
|---|---|---|
| activity_idPK | INT | Unique activity identifier |
| matter_id | INT | References matters.matter_id |
| activity_type | VARCHAR(40) | Type of activity |
| activity_at | TIMESTAMP | When the activity occurred |
| is_archived | BOOLEAN | Whether the activity is archived |