How do you compare two tables and identify changed records in SQL?
Compare the two provided table snapshots using record_id as the business key. Return only records that were added, deleted, or modified, including the before and after values.
record_id, change_type, old_customer_name, new_customer_name, old_status, new_status, old_credit_limit, and new_credit_limit.record_id ascending.| Column | Type | Description |
|---|---|---|
| record_idPK | INT | Stable record identifier from the previous snapshot |
| customer_name | VARCHAR(100) | Customer name in the previous snapshot |
| status | VARCHAR(20) | Customer status in the previous snapshot |
| credit_limit | NUMERIC(12,2) | Approved credit limit in the previous snapshot |
| Column | Type | Description |
|---|---|---|
| record_idPK | INT | Stable record identifier from the current snapshot |
| customer_name | VARCHAR(100) | Customer name in the current snapshot |
| status | VARCHAR(20) | Customer status in the current snapshot |
| credit_limit | NUMERIC(12,2) | Approved credit limit in the current snapshot |