How does the SQL MERGE statement work (upsert into a target table)?
Asked in the Technical interview stage. Listed by the candidate as asked in their HCL Data Engineer (4+ YOE) interview. Write SQL to apply the staged catalog rows to the target catalog.
item_code, item_name, category, unit_price, and active.item_code ascending.| Column | Type | Description |
|---|---|---|
| item_codePK | VARCHAR(12) | Unique catalog item code |
| item_name | VARCHAR(100) | Catalog item name |
| category | VARCHAR(40) | Product category |
| unit_price | NUMERIC(10,2) | Current price per unit |
| active | BOOLEAN | Whether the item is currently active |
| Column | Type | Description |
|---|---|---|
| item_codePK | VARCHAR(12) | Unique staged catalog item code |
| item_name | VARCHAR(100) | Staged item name |
| category | VARCHAR(40) | Staged product category |
| unit_price | NUMERIC(10,2) | Staged price per unit |
| active | BOOLEAN | Staged active status |