SalehRaceDay NFTs-total
    Updated 2022-10-22
    --****************************************Flow Price****************************************
    with lst_price as (
    select
    timestamp::date as avg_day
    ,avg (price_usd) as flow_price
    from flow.core.fact_prices
    where symbol ='FLOW'
    group by 1
    )
    --****************************************End Price****************************************
    select
    datediff(day,min(block_timestamp),max(block_timestamp)) as active_days
    ,count (DISTINCT tx_id) as sales
    ,count (DISTINCT nft_id) as nfts
    ,count (DISTINCT seller) as sellers
    ,count (DISTINCT buyer) as buyers
    ,sum(iff(currency='A.1654653399040a61.FlowToken',price*flow_price,price)) as volume_usd
    ,median(iff(currency='A.1654653399040a61.FlowToken',price*flow_price,price)) as median_price_usd
    ,max(iff(currency='A.1654653399040a61.FlowToken',price*flow_price,price)) as max_price_usd
    ,avg(iff(currency='A.1654653399040a61.FlowToken',price*flow_price,price)) as avg_price_usd
    ,sales/active_days as daily_sales_rate
    ,(volume_usd/active_days) as "Average daily sales volume $USD"
    ,(volume_usd/(active_days/7)) as "Average weekly sales volume $USD"
    ,(volume_usd/(active_days/30)) as "Average monthly sales volume $USD"
    ---*************************************Mint Query****************************************
    ,(select count (distinct tx_id) as Mints from flow.core.fact_events
    where event_contract = 'A.329feb3ab062d289.RaceDay_NFT'
    and event_type = 'Minted') as Mints
    ---**********************************End Mint Query***************************************
    from flow.core.ez_nft_sales
    join lst_price on avg_day = block_timestamp::date
    where nft_collection = 'A.329feb3ab062d289.RaceDay_NFT'
    and tx_succeeded = true
    Run a query to Download Data