nitsNFL Sales
    Updated 2023-04-15
    SELECT date(block_timestamp) as day,
    case when day >= CURRENT_DATE -7 then 'current' else 'past' end as type ,
    count(DISTINCT tx_id) as total_txs,
    count(DISTINCT buyer) as total_buyers,
    COUNT(DISTINCT seller) as total_sellers,
    sum(price) as total_vol,
    sum(total_vol) over ( order by day) as cum_vol,
    avg(price) as avg_price,
    min(price) as min_price,
    max(price) as max_price,
    avg(avg_price) over (partition by type ORDER BY Day ROWS BETWEEN {{ma}} PRECEDING AND CURRENT ROW) as moving_avg_avg_price,
    max(max_price) over (partition by type ORDER BY day ROWS BETWEEN {{ma}} PRECEDING AND CURRENT ROW) as moving_avg_max_price,
    min(min_price) over (partition by type ORDER BY Day ROWS BETWEEN {{ma}} PRECEDING AND CURRENT ROW) as moving_avg_min_price,
    sum(total_vol) over (partition by type ORDER BY Day ROWS BETWEEN {{ma}} PRECEDING AND CURRENT ROW) as moving_avg_total_vol,
    sum(total_txs) over (partition by type ORDER BY Day ROWS BETWEEN {{ma}} PRECEDING AND CURRENT ROW) as moving_avg_total_txs,
    avg(total_buyers) over (partition by type ORDER BY Day ROWS BETWEEN {{ma}} PRECEDING AND CURRENT ROW) as moving_avg_avg_buyers,
    avg(total_buyers) over (partition by type order by day) as avg_buyer_count,
    sum(total_txs) over ( order by day) as cum_txs ,
    avg(total_txs) over (partition by type order by day) as avg_txs
    from flow.core.ez_nft_sales
    where nft_collection = 'A.e4cf4bdc1751c65d.AllDay' and tx_succeeded = TRUE and day >= CURRENT_DATE - {{n}}
    GROUP by 1
    Run a query to Download Data