Created
May 21, 2019 20:40
-
-
Save ramses-lopez/ab7abdcff685f40faeb9977bbc392fa5 to your computer and use it in GitHub Desktop.
Example query for finding duplicates and using window functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
opportunities.id "opp_id", | |
title, | |
expiry_date, | |
ROW_NUMBER() OVER dupes, | |
FIRST_VALUE(opportunities.id) OVER dupes "parent" | |
FROM opportunities | |
WINDOW dupes AS (PARTITION BY opportunities.title, opportunities.expiry_date ORDER BY opportunities.created_at) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment