Updated 2022-10-22
    with flowpricet as (
    select TIMESTAMP::date as day, avg (price_usd) as flowprice
    from flow.core.fact_prices
    where symbol ='FLOW' and source ='coinmarketcap'
    group by 1),

    maintable as (
    select buyer,
    count (distinct tx_id) as Sales_Count,
    count (distinct nft_id) as Tokens_Count,
    sum (case when t1.currency ='A.1654653399040a61.FlowToken' then t1.price * t2.flowprice else t1.price end) as Total_USD_Volume
    from flow.core.ez_nft_sales t1 join flowpricet t2 on t1.block_Timestamp::Date = t2.day
    where nft_collection = 'A.329feb3ab062d289.RaceDay_NFT'
    and tx_succeeded = 'TRUE'
    group by 1)

    select avg (sales_count), avg(tokens_count), avg (total_usd_volume)
    from maintable
    Run a query to Download Data