sakineh5021-nIQRzBUntitled Query
    Updated 2022-04-11
    with pool as (
    SELECT POOL_ADDRESS , POOL_NAME
    FROM ethereum.dex_liquidity_pools
    where platform ='sushiswap'
    ) ,
    per as (
    SELECT POOL_NAME , balance_date , max(balance) as max_LP ,sum(balance) as total , max_LP/total*100 as percent
    from ethereum.erc20_balances
    left outer join pool P on POOL_ADDRESS = contract_address
    where POOL_NAME is not NULL
    and balance is not null
    and balance_date >'2021-01-01'
    group by 1 , 2
    ),
    more as (
    SELECT balance_date , count(POOL_NAME) as more_pools
    from per
    where percent >50
    group by 1 )

    , tot as (
    SELECT balance_date , count(POOL_NAME) as total_pools
    from per
    group by 1
    )
    SELECT T.balance_date , more_pools/total_pools*100 as percent ,more_pools/total_pools as ratio
    from tot T , more M
    where T.balance_date = M.balance_date
    Run a query to Download Data