select mid,month(dateinserted) as Month,
sum(txn_amount) failedGMV
from (
select
transactionid,
max(dateinserted) dateinserted ,
max(cast(eventamount as double)/100) txn_amount            ,
max(paytmmerchantid) mid 
from
cdp_risk_transform.maquette_flattened_offus_snapshot_v3
where 
dl_last_updated >= date'2024-10-01'
and DATE (dateinserted)  between date '2024-10-01' and date '2025-01-31'
AND actionrecommended = 'BLOCK'
group by 1)
group by 1,2