Rule 1
Tue Apr 25 2023 06:30:51 GMT+0000 (Coordinated Universal Time)
Saved by
@saumyatiwari
select A.receiveruser, A.max_for_previous_month, B.max_for_current_month, ((B.max_for_current_month - A.max_for_previous_month )/ B.max_for_current_month ) as percent_jump
from
(Select receiveruser, max(totaltransactionamount) as max_for_previous_month
from fraud.transaction_details_v3
where updated_date between '2023-01-01' and '2023-01-31' and receivertype = 'MERCHANT' and receiversubtype In ('OFFLINE_UNORGANISED','OFFLINE_THROUGH_AGGREGATOR','P2P_MERCHANT','P2M_LIMITED','OFFLINE_AGGREGATOR') and errorcode = 'SUCCESS' and backend_errorcode = 'SUCCESS' and pay_transaction_status = 'COMPLETED'
group by receiveruser
having max(totaltransactionamount) > 10000)A
left join
(Select receiveruser , max(totaltransactionamount) as max_for_current_month
from fraud.transaction_details_v3
where updated_date between '2023-02-01' and '2023-02-28' and receivertype = 'MERCHANT' and receiversubtype In ('OFFLINE_UNORGANISED','OFFLINE_THROUGH_AGGREGATOR','P2P_MERCHANT','P2M_LIMITED','OFFLINE_AGGREGATOR') and errorcode = 'SUCCESS' and backend_errorcode = 'SUCCESS' and pay_transaction_status = 'COMPLETED'
group by receiveruser
having max(totaltransactionamount) > 10000)B
on A.receiveruser = B.receiveruser
group by A.receiveruser, A.max_for_previous_month, B.max_for_current_month
--where (B.max_for_current_month/A.max_for_previous_month) > 0.8
order by percent_jump desc
limit 1000
content_copyCOPY
Comments