Skip to content

Instantly share code, notes, and snippets.

@vvgsrk
Last active April 26, 2022 10:55
Show Gist options
  • Save vvgsrk/e3e519cd20f01313d56112cb3f864629 to your computer and use it in GitHub Desktop.
Save vvgsrk/e3e519cd20f01313d56112cb3f864629 to your computer and use it in GitHub Desktop.
Product Info Latest
WITH product_info AS (
SELECT
ROW_NUMBER() over (
PARTITION BY product_id
ORDER BY
__event_ts DESC
) AS row_rank,*
FROM
{{ ref('src_product_management_product_history') }}
)
SELECT
*
FROM
product_info
WHERE
row_rank = 1
ORDER BY
product_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment