nits Fifa Sale Stats
    Updated 2022-12-15
    with meta as (SELECT nft_asset_id as nai , rarity as buy_type from algorand.nft.ez_nft_metadata_fifa ),
    fifa as (SELECT * from
    algorand.nft.ez_nft_sales_fifa
    join meta on nft_asset_id = nai
    )
    SELECT
    date(block_timestamp) as day, buy_type,
    count(DISTINCT tx_group_id) as total_txs,
    count(DISTINCT purchaser) as total_buyers,
    sum(total_sales_amount_usd) as total_amt_usd,
    sum(total_amt_usd) over (partition by buy_type order by day) as cum_amt,
    sum(total_txs) over (partition by buy_type order by day) as cum_txs,
    min(total_sales_amount_usd) as floor_price,
    avg(total_sales_amount_usd) as avg_price,
    max(total_sales_amount_usd) as max_price,
    min(floor_price) over (partition by buy_type order by day rows between {{ma}} preceding and CURRENT row ) as floor_price_moving_avg,
    max(max_price) over (partition by buy_type order by day rows between {{ma}} preceding and CURRENT row) as max_price_moving_avg
    from fifa
    where date(block_timestamp) >= CURRENT_DATE - {{n}} and sale_type = 'secondary'
    GROUP by 1, 2
    -- LIMIT 100
    Run a query to Download Data