Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 30 Jan 2002 @ 13:25:22 GMT


     
  <Prev Next>   <<First <Prev
Next>
Last>>
 


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)



     
  <Prev Next>   <<First <Prev
Next>
Last>>
 
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023