How to Remove Duplicates in Snowflake

Last updated July 25, 2026 · By the SaturnSQL team

Deduplicate by key with ROW_NUMBER() and QUALIFY, keeping one row per group, then rewrite the table with CREATE OR REPLACE TABLE AS SELECT. For fully identical rows, SELECT DISTINCT is enough.

Keep the latest row per key

CREATE OR REPLACE TABLE orders AS
SELECT *
FROM orders
QUALIFY ROW_NUMBER() OVER (
  PARTITION BY id ORDER BY created_at DESC
) = 1;

Fully identical rows

When every column is duplicated, DISTINCT removes the copies without needing a key.

INSERT OVERWRITE INTO orders
SELECT DISTINCT * FROM orders;

Both approaches rewrite the table, so the previous version stays recoverable via Time Travel for the retention period. Verify the row count before and after.

Run this in SaturnSQL

SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.

Try it free

Related Snowflake guides

© 2026 Panda Capital Oy Ab. All rights reserved.