Write a SQL query using window functions to identify the most recent risk rating change for a set of monitored organizations.
Use the provided organization and rating history data. Include only actual rating changes for monitored organizations.
organization_id, organization_name, changed_at, previous_rating, current_ratingorganization_id ascending, with the most recent change selected per organization| Column | Type | Description |
|---|---|---|
| organization_idPK | INTEGER | Unique organization identifier |
| organization_name | VARCHAR(150) | Organization display name |
| monitored | BOOLEAN | Whether the organization is currently monitored |
| Column | Type | Description |
|---|---|---|
| rating_change_idPK | INTEGER | Unique rating history record identifier |
| organization_id | INTEGER | Organization associated with the rating event |
| previous_rating | VARCHAR(30) | Rating before the event |
| current_rating | VARCHAR(30) | Rating after the event |
| changed_at | TIMESTAMP | Timestamp when the rating event was recorded |
| changed_by | VARCHAR(100) | Actor or process that recorded the event |