-
-
Save vatsan/3e38e90bf4083868f46a to your computer and use it in GitHub Desktop.
Window Function to sample 10 elements at random for each group.
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 | |
* | |
from | |
( | |
select | |
group, | |
row_number() over(partition by group order by random()) as row_number | |
from | |
table | |
)q | |
where | |
row_number <=10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment