select random users sql -
in 1 of tables have listing of purchases userid, date, products, channels, etc. i'd select random set of users can run sample analysis. if use rand(), have chance of excluding user's 2nd, 3rd, nth purchase us. what's best way grab 50, 100, 60000 random users , see of purchases?
select userid, date, sku, campaign, device date between '2014-05-01' , '2014-05-31' sales
this select top(x) users, , sales data them.
declare @samplerate int set @samplerate = 50 select s.userid, s.date, s.sku, s.campaign, s.device sales s join (select top(@samplerate) rand() rnd, x.userid (select distinct userid sales) x order rnd) y on s.userid = y.userid s.date between '2014-05-01' , '2014-05-31'
Comments
Post a Comment