Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 02:16 AM
Yep, I was thinking the same. The only way I know is to have a seperated INSERT INTO command before the MERGE INTO.
INSERT INTO target_table (
columns,
effectiveStartDate,
effectiveEndDate,
isCurrent,
version
)
SELECT
new.columns,
DATE(new.timestamp),
DATE('9999-12-31'),
TRUE,
target.version + 1
FROM df as new
LEFT JOIN destination_table as target
ON new.customerId = target.customerId and target.isCurrent
WHERE (
target.column <> new.column
OR target.column <> new.column
)