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/withtrade as (selectdate_trunc('{{Time Granularity}}', block_time) as time, blockchain, sum(amount_usd) filter(where project = 'uniswap') as vol, count(*) filter(where project = 'uniswap') as swap, count(distinct tx_from) filter(where project = 'uniswap') as user, sum(amount_usd) as ttl_vol, count(*) as ttl_swap, count(distinct tx_from) as ttl_userfrom dex.tradeswhere 1=1and date(block_time) < date_trunc('{{Time Granularity}}', now())and not ((token_bought_symbol = 'LIT' and date(block_time) between date '2021-12-01' and date '2022-09-30')or (token_bought_symbol = 'POP' and date(block_time) = date '2021-02-12')or (token_bought_symbol = 'JOY' and date(block_time) = date '2022-07-28')or (token_bought_symbol = 'RNBW' and date(block_time) = date '2022-10-08')or (token_bought_symbol = 'PRXY' and date(block_time) between date '2021-11-16' and date '2021-12-09')) -- wrong volume datagroup by 1,2)selecttime, blockchain, vol, swap, user, vol/ttl_vol as "% in Chain Total Volume", cast(swap as double)/cast(ttl_swap as double) as "% in Chain Total # Swaps", cast(user as double)/cast(ttl_user as double) as "% in Chain Total # Users"from tradewhere vol is not null