adriaparcerisasflow stats: yearly nft sales
    Updated 2024-01-06


    with
    prices as (
    select
    trunc(timestamp,'hour') as hour,
    token_contract,
    avg(price_usd) as price_usd
    from flow.price.fact_prices
    where timestamp<'2024-01-01'

    group by 1,2
    ),
    final as (
    SELECT
    trunc(block_timestamp,'year') as year,
    count(distinct tx_id) as sales,
    sum(sales) over (order by year) as total_sales,
    count(distinct buyer) as nft_buyers,
    sum(price*price_usd) as volume,
    sum(volume) over (order by year) as total_volume,
    count(distinct nft_collection) as active_collections
    from flow.nft.ez_nft_sales x
    join prices y on trunc(x.block_timestamp,'hour')=hour
    and x.currency=y.token_contract
    where tx_succeeded='true'
    and x.block_timestamp<'2024-01-01'

    group by 1
    order by 1 asc
    ),
    final2 as (
    SELECT
    trunc(block_timestamp,'year') as year,
    count(distinct tx_id) as sales,
    sum(sales) over (order by year) as total_sales,
    QueryRunArchived: QueryRun has been archived