HadisehQuixotic NFT 4
    Updated 2022-10-06
    with t1 as ( select
    trunc(hour,'day') as price_day,
    symbol ,
    avg(price) as avg_price
    from optimism.core.fact_hourly_token_prices
    where symbol in ('WETH','OP') and hour >= CURRENT_DATE - 30
    group by price_day, symbol
    )
    ,
    t2 as ( select
    price_day,
    case when symbol = 'WETH' then 'ETH' else symbol end as token, avg_price
    from t1)
    ,
    t3 as ( select
    trunc(block_timestamp,'day') as day ,
    tx_hash,
    buyer_address,
    seller_address,
    nft_address,
    CURRENCY_SYMBOL,
    price,
    price*avg_price as price_usd
    from optimism.core.ez_nft_sales x left outer join t2 b on x.block_timestamp::date = b.price_day
    where CURRENCY_SYMBOL = token)
    ,
    t4 as ( select nft_address ,
    sum(price_usd) as total_volume
    from t3
    group by nft_address
    order by 2 desc
    limit 5)

    select case when nft_address = '0x81b30ff521d1feb67ede32db726d95714eb00637' then 'Optimistic Explorer'
    when nft_address = '0x51e5426ede4e2d4c2586371372313b5782387222' then 'Apetimism'
    when nft_address = '0x18a1bc18cefdc952121f319039502fdd5f48b6ff' then 'CryptoTesters '
    Run a query to Download Data