Query editor
with-- Базовые данные адресов Binancebinance_addresses as (selectaddress,entity,distinct_name,track_inflow,track_outflow,inverse_valuesfrom query_7700107where entity = 'Binance'),-- Ежедневные притоки и оттокиdaily_flows as (selectdate_trunc('day', block_time) as block_date,entity,distinct_name,-- Притоки (вводы на биржу)sum(casewhen i.type = 'output' and b.track_inflow = true thencase when b.inverse_values = true then -i.value else i.value endelse 0end) as daily_inflow,-- Оттоки (выводы с биржи)sum(casewhen i.type = 'input' and b.track_outflow = true thencase when b.inverse_values = true then i.value else -i.value endelse 0end) as daily_outflowfrom (-- Outputs (притоки)selecto.address,o.block_time,o.value,'output' as typefrom bitcoin.outputs owhere o.value > 0and o.block_time > date(try_cast('2019-07-24' as timestamp))union all-- Inputs (оттоки)selecti.address,i.block_time,i.value,'input' as typefrom bitcoin.inputs iwhere i.value > 0and i.block_time > date(try_cast('2019-07-24' as timestamp))) iinner join binance_addresses b on b.address = i.addresswhere (i.type = 'output' and b.track_inflow = true)