How to fetch a sample of data within each group - Teradata
Scenario: We need to select a random sample of 5 in each status type
TABLE1
MEMBER | STATUS |
89 | A |
34 | A |
25 | R |
27 | S |
69 | J |
32 | R |
39 | J |
55 | S |
32 | A |
Solution:
\n\nSEL Member, status \nFROM TABLE1 \nQUALIFY ROW_NUMBER() OVER (\n PARTITION BY status \n ORDER BY NULL) <= 50;
nVector
posted onEnjoy great content like this and a lot more !
Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds
Post Comment