Query editor
-- This query used incompatible data types from Dune SQL alpha and may need to be updated.-- More details can be found on https://dune.com/docs/query/dunesql-changes/with spent_info as(SELECTaddress,spent_tx_id,value,block_time as spent_time,date_trunc('day', block_time) as stat_dateFROM bitcoin.inputswhere date_trunc('day', block_time) >= date_trunc('day', NOW()) - INTERVAL '30' DAY),receive_info as(selectaddress,tx_id,block_time as receive_timefrom bitcoin.outputs-- where address in (select address from spent_info group by address )),cdd_matrix as(selectstat_date,round(sum(value),0) as volumn,round(sum(cdd_value),0) as cddfrom(selectaddress,value,(data_held /24) * value as cdd_value,stat_datefrom(selectspent_info.address as address,value,spent_time,receive_time,date_diff('hour',receive_time,spent_time) as data_held,stat_datefrom(SELECTaddress,spent_tx_id,value,spent_time,stat_dateFROM spent_info) spent_infoleft join(selectaddress