MahrooUntitled Query
    Updated 2022-11-20
    with pricet as (
    select timestamp::Date as day,
    token,
    symbol,
    token_contract,
    avg (price_usd) as USDPrice
    from flow.core.fact_prices
    where token != 'Blocto'
    group by 1,2,3,4)

    select trader,
    count (distinct tx_id) as Swaps_Count,
    sum (case when token_in_contract = token_contract then token_in_amount
    when token_out_contract = token_contract then token_out_amount end) as Total_Token_Volume,
    sum (case when token_in_contract = token_contract then token_in_amount*usdprice
    when token_out_contract = token_contract then token_out_amount*usdprice end) as Total_USD_Volume
    from flow.core.ez_swaps t1 join pricet t2 on (t1.token_in_contract = t2.token_contract or t1.token_out_contract = t2.token_contract) and t1.block_timestamp::Date = t2.day
    where symbol ilike 'Flow'
    and token_in_contract = token_contract
    group by 1
    order by Swaps_Count DESC
    limit 10
    Run a query to Download Data