Write an SQL query to identify the most recent defect for each test case.
Return all test cases, including those without a linked defect. The most recent defect is determined by the latest reported_at timestamp; if timestamps tie, choose the defect with the greatest defect_id.
test_case_id.test_case_id, test_case_name, defect_id, defect_title, reported_at, and severity.| Column | Type | Description |
|---|---|---|
| test_case_idPK | INT | Unique test case identifier |
| test_case_name | VARCHAR(150) | Test case name |
| test_suite | VARCHAR(100) | Test suite containing the case |
| Column | Type | Description |
|---|---|---|
| defect_idPK | INT | Unique defect identifier |
| defect_title | VARCHAR(200) | Short defect description |
| reported_at | TIMESTAMP | Timestamp when the defect was reported |
| severity | VARCHAR(20) | Defect severity |
| Column | Type | Description |
|---|---|---|
| test_case_idPK | INT | Referenced test case |
| defect_idPK | INT | Referenced defect |
| link_status | VARCHAR(20) | Status of the test case to defect relationship |