mitchperionSorare Stats copy
    Updated 2023-05-30
    -- forked from nits / Sorare Stats @ https://flipsidecrypto.xyz/nits/q/untitled-query-RpUWDj

    SELECT date(block_timestamp) as day,
    count(DISTINCT tx_hash) as total_txs,
    COUNT(DISTINCT buyer_address) as unique_buyers,
    COUNT(DISTINCT seller_address) as unique_sellers,
    sum(price_usd) as total_vol, sum(tx_fee_usd)as total_fee_usd ,
    avg(price_usd) as avg_price,
    min(price_usd) as floor_price,
    max(price_usd) as max_price,
    avg(avg_price) over (order by day roWS BETWEEN {{moving_avg}} PRECEDING AND CURRENT ROW ) as avg_price_over_time,
    min(floor_price) over (order by day roWS BETWEEN {{moving_avg}} PRECEDING AND CURRENT ROW ) as floor_price_over_time,
    avg(max_price) over (order by day roWS BETWEEN {{moving_avg}} PRECEDING AND CURRENT ROW ) as max_price_over_time,
    sum(total_txs) over (order by day roWS BETWEEN {{moving_avg}} PRECEDING AND CURRENT ROW ) as total_txs_over_time,
    avg(total_vol) over (order by day roWS BETWEEN {{moving_avg}} PRECEDING AND CURRENT ROW ) as total_vol_over_time,
    avg(total_fee_usd) over (order by day roWS BETWEEN {{moving_avg}} PRECEDING AND CURRENT ROW ) as total_fee_over_time
    from ethereum.core.ez_nft_sales
    where project_name ilike '%mavia_land%' and day >= CURRENT_DATE - {{last_n_days}}
    GROUP by 1
    -- LIMIT 100


    Run a query to Download Data