Updated 2022-12-05
    with price as (
    select
    timestamp::date as day,
    avg(price_usd) as flow_price
    from flow.core.fact_prices
    where token_contract = 'A.1654653399040a61.FlowToken'
    group by 1
    ),
    base as (
    select
    *,
    case
    when currency in ('A.ead892083b3e2c6c.FlowUtilityToken', 'A.1654653399040a61.FlowToken') then price * flow_price else price end as nft_price
    from flow.core.ez_nft_sales join price on block_timestamp::date = day
    where
    nft_collection = 'A.e4cf4bdc1751c65d.AllDay' and tx_succeeded = 'TRUE'
    )
    select
    date_trunc('day', block_timestamp) as date,
    case when date = '2022-11-24' then 'Thanksgiving day-2022'
    when date > '2022-11-24' and date<='2022-12-01' then 'One week After Thanksgiving-2022'
    when date < '2022-11-24' and date>='2022-11-17' then 'One week before Thanksgiving-2022'
    when date < '2022-11-17' and date>='2022-11-10' then 'Two week before Thanksgiving-2022'
    when date < '2022-11-10' and date>='2022-11-03' then 'Three week before Thanksgiving-2022'
    else 'Other days' end as period,
    count(distinct tx_id) as sales_count,
    count(distinct buyer) as unique_buyer,
    count(distinct seller) as unique_seller,
    avg(flow_price) as flow_price,
    sum(nft_price) as sales_volume,
    avg(nft_price) as avg_nft_price,
    median(nft_price) as median_nft_price,
    sum(sales_count) over (order by date) as cum_sales_count,
    sum(unique_buyer) over (order by date) as cum_unique_buyer,
    sum(unique_seller) over (order by date) as cum_unique_seller,
    sum(sales_volume) over (order by date) as cum_sales_volume,
    Run a query to Download Data