Your question is SQL MERGE Practice. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Write code to perform a SQL MERGE query.
Asked in the 1st Round Technical Interview stage. SQL coding prompt. Apply the source records to the target records using record_id as the matching key. Matching rows must be updated, and source rows without a target match must be inserted.
record_id, record_value, status, and updated_atrecord_id ascending| Column | Type | Description |
|---|---|---|
| record_idPK | INT | Unique identifier for the target record |
| record_value | VARCHAR(100) | Current value stored in the target |
| status | VARCHAR(20) | Current processing status |
| updated_at | DATE | Date the target record was last updated |
| Column | Type | Description |
|---|---|---|
| record_idPK | INT | Unique identifier for the incoming record |
| record_value | VARCHAR(100) | Incoming record value |
| status | VARCHAR(20) | Incoming processing status |
| updated_at | DATE | Date associated with the incoming record |