Query editor
with days as (with time_seq as (SELECTsequence(cast('2025-01-22' as timestamp), date_trunc('day', cast(now() as timestamp)), interval '1' day) as time)SELECTtimes.timeFROM time_seqLEFT JOIN unnest(time) as times(time) on true--where times.time > DATE_TRUNC('day', NOW()) - INTERVAL '3' day),inflow as (select date_trunc('day',block_time) as day ,symbol, sum(amount_display) as sol_amount, sum(amount_usd) as usd_amountfrom tokens_solana.transferswhere --date_trunc('day', block_time) > DATE_TRUNC('day', NOW()) - INTERVAL '3' dayouter_executing_account = 'HVdfohHjp1kZwxn123Cxv3GDeXeXnLM1RAXaF8dPYBdS'and to_owner = 'GwXEzAYMQkZJr2VgiPfp5BtJoh7tBuFhM7djkMNzAiTT' and symbol = 'SOL'group by 1,2),outflow as (select date_trunc('day',block_time) as day ,symbol, sum(amount_display) as sol_amount, sum(amount_usd) as usd_amountfrom tokens_solana.transferswhere --date_trunc('day', block_time) > DATE_TRUNC('day', NOW()) - INTERVAL '3' dayouter_executing_account = 'HVdfohHjp1kZwxn123Cxv3GDeXeXnLM1RAXaF8dPYBdS'and from_owner = 'GwXEzAYMQkZJr2VgiPfp5BtJoh7tBuFhM7djkMNzAiTT' and symbol = 'SOL'group by 1,2),balance as (selectd.time as day,coalesce(i.sol_amount,0) as sol_in,coalesce(i.usd_amount,0) as usd_in,coalesce(o.sol_amount,0) as sol_out,coalesce(o.usd_amount,0) as usd_out,coalesce(i.sol_amount,0) - coalesce(o.sol_amount,0) as sol_inflow,coalesce(i.usd_amount,0) - coalesce(o.usd_amount,0) as usd_inflowfrom days dleft join inflow ion i.day = d.timeleft join outflow oon o.day = d.time)select * from balance