banned users
Mon Aug 09 2021 10:25:54 GMT+0000 (UTC)
Saved by @alvaroferrer #sql #bigquery #datastudio
--usuarios con varias tarjetas SELECT concat('https://admin.reby.tech/riders/usr_', id_to_text(ppg.user_id)), count(distinct(card__fingerprint)) FROM payment_processor_gateway ppg LEFT JOIN banned_device bd ON ppg.user_id=bd.user_id where reason is null GROUP BY 1 having count(distinct(card__fingerprint))>5 ORDER BY 2 DESC LIMIT 100; --tarjetas utilizadas por varias cuentas SELECT --concat('https://admin.reby.tech/riders/usr_', id_to_text(ppg.user_id)), card__fingerprint, card__last_four, count(distinct(ppg.user_id)) FROM payment_processor_gateway ppg left join public.user on public.user.id=ppg.user_id LEFT JOIN banned_device bd ON ppg.user_id=bd.user_id where reason is null and card__fingerprint is not null GROUP BY 1,2 having count(distinct(ppg.user_id))>3 ORDER BY 3 DESC; --usuarios que utilizan la tarjeta con código que introduzcáis: SELECT distinct(concat('https://admin.reby.tech/riders/usr_', id_to_text(ppg.user_id))), --distinct(ppg.user_id), card__fingerprint FROM payment_processor_gateway ppg LEFT JOIN banned_device bd ON ppg.user_id=bd.user_id where reason is null and card__fingerprint='+7qy4w/5VsCCCtwf' ORDER BY 1 DESC LIMIT 100 --usuarios que han utilizado tarjetas que se han utilizado en más de 5 cuentas with data as (SELECT --concat('https://admin.reby.tech/riders/usr_', id_to_text(ppg.user_id)), card__fingerprint, count(distinct(ppg.user_id)) FROM payment_processor_gateway ppg left join public.user on public.user.id=ppg.user_id LEFT JOIN banned_device bd ON ppg.user_id=bd.user_id where reason is null and card__fingerprint is not null and public.user.is_staff is false and public.user.is_deleted=false GROUP BY 1 having count(distinct(ppg.user_id))>3 ORDER BY 2 DESC) select distinct(public.user.phone_number), public.user.first_name, public.user.last_name --data.card__fingerprint --distinct(ppg.user_id), FROM data left join payment_processor_gateway ppg on ppg.card__fingerprint=data.card__fingerprint left join public.user on public.user.id=ppg.user_id and public.user.is_staff is false and public.user.phone_number is not null --order by data.card__fingerprint; --usuarios con dispositivos en los que se han registrado más de 5 cuentas with data as (SELECT hash_device, count(hash_device) as number_accounts FROM user_device ud GROUP BY 1 HAVING count(hash_device)>=5 ORDER BY 2 desc) SELECT distinct(public.user.phone_number), public.user.first_name, public.user.last_name, public.user.phone_number, --data.hash_device, service_area.name, user_last_location.last_location_at FROM DATA LEFT JOIN user_device ud ON ud.hash_device=data.hash_device LEFT JOIN public.user ON public.user.id=ud.user_id AND public.user.is_staff IS FALSE AND public.user.phone_number IS NOT NULL and public.user.is_deleted=false left join user_last_location on public.user.id=user_last_location.user_id left join service_area on user_last_location.last_service_area_id = service_area.id where service_area.name='Terrassa' ORDER BY user_last_location.last_location_at desc ; --Análisis usuario Alba SELECT distinct(concat('https://admin.reby.tech/riders/usr_', id_to_text(ppg.user_id))), --distinct(ppg.user_id), card__fingerprint, card__last_four FROM payment_processor_gateway ppg LEFT JOIN banned_device bd ON ppg.user_id=bd.user_id where /* reason is null and*/ card__last_four in('1058','9219') ORDER BY 1 DESC LIMIT 100 --usuarios que se han registrado en más de 5 dispositivos y balance negativo with data as (SELECT id_to_text(user_id) as user_id, count(hash_device) as number_devices FROM user_device ud GROUP BY 1 HAVING count(hash_device)>=5 ORDER BY 2 desc) SELECT public.user.first_name, public.user.last_name, public.user.phone_number, data.user_id, data.number_devices, service_area.name, user_last_location.last_location_at, account.balance__amount FROM DATA LEFT JOIN public.user ON id_to_text(public.user.id)=data.user_id AND public.user.is_staff IS FALSE AND public.user.phone_number IS NOT NULL and public.user.is_deleted=false left join user_last_location on public.user.id=user_last_location.user_id left join service_area on user_last_location.last_service_area_id = service_area.id left join account on public.user.balance_account_id=account.id where service_area.name='Terrassa' and account.balance__amount<0 ORDER BY user_last_location.last_location_at desc ;
Comments