Created
June 9, 2024 18:21
-
-
Save judell/d023341e4f8aa3f73149e11b0e27ba7b to your computer and use it in GitHub Desktop.
org members using dense_rank
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
WITH cte AS ( | |
SELECT | |
org_handle, | |
user_handle, | |
status, | |
ROW_NUMBER() OVER (PARTITION BY org_handle ORDER BY user_handle) AS rn, | |
DENSE_RANK() OVER (ORDER BY org_handle) AS org_rank | |
FROM | |
pipes_organization_member | |
) | |
SELECT | |
CASE | |
WHEN rn = 1 THEN org_handle | |
ELSE '' | |
END AS org_handle, | |
user_handle, | |
status | |
FROM | |
cte | |
ORDER BY | |
org_rank, | |
rn; | |
EOQ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment