Write a SQL query to identify duplicate survey responses within a database table, keeping only the most recent entry.
Treat rows with the same survey_id, respondent_id, and question_id as duplicates. Return one row for each combination, retaining the response with the latest submitted_at; if timestamps tie, retain the row with the greatest response_id.
response_id, survey_id, respondent_id, question_id, response_text, and submitted_atsurvey_id, respondent_id, question_id| Column | Type | Description |
|---|---|---|
| response_idPK | INT | Unique identifier for the submitted response |
| survey_id | INT | Identifier of the survey |
| respondent_id | INT | Identifier of the respondent |
| question_id | INT | Identifier of the survey question |
| response_text | VARCHAR(100) | Submitted answer text |
| submitted_at | TIMESTAMP | Timestamp when the response was submitted |