Created
August 12, 2021 16:29
-
-
Save William9923/2b8eaee4528aa9dcab982a0bb2071ad0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 user_name , customer_zip_code , customer_city , customer_state | |
| from ( | |
| SELECT | |
| DISTINCT *, | |
| RANK() over( | |
| PARTITION BY user_name | |
| ORDER BY customer_zip_code DESC, customer_state DESC , customer_city DESC | |
| ) as rank | |
| FROM | |
| live.user u | |
| ) dedup | |
| where rank = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment