Skip to content

Instantly share code, notes, and snippets.

@sqlparser
Created December 12, 2023 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sqlparser/d78009beb44f3bd1ec2dc90748ea380a to your computer and use it in GitHub Desktop.
Save sqlparser/d78009beb44f3bd1ec2dc90748ea380a to your computer and use it in GitHub Desktop.
Trino Sample SQL
```sql
MERGE INTO accounts t USING monthly_accounts_update s
ON (t.customer = s.customer)
WHEN MATCHED AND s.address = 'Centreville'
THEN DELETE
WHEN MATCHED
THEN UPDATE
SET purchases = s.purchases + t.purchases, address = s.address
WHEN NOT MATCHED
THEN INSERT (customer, purchases, address)
VALUES(s.customer, s.purchases, s.address)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment