create table tmp_abc (
) partitioned by (slot string)
row format delimited fields terminated by '\t' lines terminated by '\n'
stored as TextFile
insert overwrite table tmp_abc partition (slot) select customer_id, email, case when slot1 < 0.10 then "a" when slot1 < 0.70 then "b" else "c" end as slot from ( select customer_id, email, rand() as slot1 from (select customer_id, max(email) as email, sum(case when seg_num >= 0 then 1 else 0 end) as included from customers where ( (seg_num in (1) and member = 'Y') or (seg_num = -1) ) and site_key = 'a_site' and coll_def_id = 'everything' group by customer_id having included > 0 ) a ) b