select advertising_id from(select ntile(7)over(order by advertising_id)ntil,advertising_id from(select distinct advertising_id from facts.public.dp_order_fact aleft joinanalytics.public.city_attributes b on a.city_id=b.city_idleft join (select * from analytics.marketing.user_level_adid_idfa_mapping_DG )ad on a.customer_id=ad.user_idleft join (select distinct customer_id::varchar customer_id from analytics.public.dineout_order_fact where status=’COMPLETED’ )d on a.customer_id=d.customer_id where 0=0 and city_name in (‘Delhi’,’Noida’,’Noida 1′) and post_status=’Completed’and d.customer_id is null))where ntil=1;