Skip to content
SQLSimplified
Data EngineerQuestion 54 of 55

UPSERT / MERGE Statement

Problem

You are syncing data from Salesforce to your data warehouse every 5 minutes. Some rows are brand new, others are updates to existing records. You need a single SQL statement that can handle both seamlessly. Write a query that outputs concept with the value: "UPSERT updates an existing row if it exists, or inserts a new row if it does not."

Database Schema

This problem acts as a scratchpad. You will write your own DDL/DML or conceptual queries, so there is no predefined schema.

Try It

Loading playground environment...

Hint

Solution