Moe8 NFT opt
    Updated 2022-10-20
    /*
    Sales volume (daily/weekly/monthly)
    Total Sales Volume
    Daily Average Sales Price and 7-day moving average
    Total Unique Buyers
    Average Buyers/Day
    */

    select
    count(distinct BUYER_ADDRESS) as buyer_count,
    count(distinct SELLER_ADDRESS) as SELLER_count,
    count(distinct tx_hash) as sale_count,
    sum(PRICE_USD) as sale_volume,

    sale_volume/buyer_count as usd_per_buyer,
    sale_volume/sale_count as usd_per_sale,
    sale_volume/ count(DISTINCT nft_address) as usd_per_collection,

    buyer_count/ {{days_back}} as buyer_per_day,

    avg (price_usd) as Avg_sale_Volume,
    max (price_usd) as Max_sale_Volume,
    median (price_usd) as Med_sale_Volume,
    min (price_usd) as Min_sale_Volume
    from optimism.core.ez_nft_sales
    where tx_hash is not NULL
    and origin_from_address != seller_address -- Secondary
    and EVENT_TYPE = 'sale'
    and price_usd > 0
    and BLOCK_TIMESTAMP >= CURRENT_DATE - {{days_back}}


    Run a query to Download Data