 |
 |
Archives of the TeradataForum
Message Posted: Wed, 30 Jan 2002 @ 13:25:22 GMT
Subj: | | Re: SAMPLE statement for multiple groups |
|
From: | | Bill Hassinger |
I don't think sample or random can insure that you get rows from all groups. If you don't have to insure randomness, you could add a
RANK to each row and GROUP BY your business groups. Then use QUALIFY to select rows with a RANK value less than the sample size you want
divided by the number of groups.
Select USER_ID, GROUP_ID, RANK(USER_ID)
From TABLE_NAME
Group By GROUP_ID
Qualify RANK(USER_ID) <= (Sample Size / 20)
| |