Skip to main content
SQL โ€ข LESSON 179

Deduplicate Source Data

How can we deduplicate Bronze raw ingestion records retaining the latest update per order?

Advancedโฑ 3 Minutesโญ 1920 XP
๐Ÿค” THE QUESTION

How can we deduplicate Bronze raw ingestion records retaining the latest update per order?

๐Ÿ’ก WHAT IS IT?

Partitioning by order_id and sorting by updated_at DESC isolates the latest clean record in bronze-to-silver staging.

๐ŸŽฏ WHAT IS IT USED FOR?

Bronze to Silver Lakehouse ELT, removing duplicate streaming deliveries, idempotent ingestion.

๐Ÿ’ป EXAMPLE
SELECT *
FROM (
    SELECT
        *,
        ROW_NUMBER() OVER (
            PARTITION BY order_id
            ORDER BY updated_at DESC
        ) AS rn
    FROM source_orders
) cleaned
WHERE rn = 1;

๐ŸŽฏ Mission Objectives

Practice typing production-grade SQL code for Deduplicate Source Data.

  • โœ“ Bronze-to-Silver deduplication
  • โœ“ Idempotent pipeline staging
  • โœ“ ROW_NUMBER partition
  • โœ“ Lakehouse curation