Query editor
with tx as (select date_trunc('week', evt_block_time) as period, "from", "to", value as amount,case when value < 100*1e6 then 100when value < 1000*1e6 then 1000when value < 10000*1e6 then 10000when value < 100000*1e6 then 100000when value < 1000000*1e6 then 1000000else -1 end as bucketfrom tether_tron.tether_usd_evt_transferwhere evt_block_time >= date'2021-01-01'and evt_block_time < date_trunc('week', current_date)),tron as (select period, sum(amount)/1e6 as amount, count(1) as tx,count(distinct "from") as senders, count(distinct "to") as receivers,sum(case when bucket = 100 then 1 else 0 end) as tx_100,sum(case when bucket = 1000 then 1 else 0 end) as tx_1000,sum(case when bucket = 10000 then 1 else 0 end) as tx_10000,sum(case when bucket = 100000 then 1 else 0 end) as tx_100000,sum(case when bucket = 1000000 then 1 else 0 end) as tx_1000000,sum(case when bucket = -1 then 1 else 0 end) as tx_1000000p,sum(case when bucket = 100 then amount else 0 end)/1e6 as amt_100,sum(case when bucket = 1000 then amount else 0 end)/1e6 as amt_1000,sum(case when bucket = 10000 then amount else 0 end)/1e6 as amt_10000,sum(case when bucket = 100000 then amount else 0 end)/1e6 as amt_100000,sum(case when bucket = 1000000 then amount else 0 end)/1e6 as amt_1000000,sum(case when bucket = -1 then amount else 0 end)/1e6 as amt_1000000pfrom txgroup by 1)select *from tronorder by period desc