PapasotAlgorand NFTs by marketplace last 30 days + USD volume
    Updated 2023-01-03
    with algo_price as (select
    avg(price_usd) as price ,
    BLOCK_HOUR::date as day
    from algorand.prices_swap
    where asset_id= 0
    GROUP by day
    order by day
    ),

    NFTS as (
    SELECT
    date_trunc('day',block_timestamp) as day,
    nft_marketplace,
    case
    when nft_marketplace = 'rand gallery' then 'Rand Gallery'
    when nft_marketplace = 'algoxnft' then 'Algoxnft'
    else 'Others' end as marketplace,
    count(distinct(purchaser)),
    count(distinct(nft_asset_id)),
    sum(total_sales_amount) as total_Algo,
    --total_Algo * b.price as total_USD,
    sum(number_of_nfts)

    from
    algorand.nft_sales
    where
    day >= CURRENT_DATE - 30
    group by day,nft_marketplace
    order by day)

    select
    a.* ,
    a.total_Algo * b.price as total_USD,
    sum(total_USD) over(ORDER by day ) as cum_total_USD
    from NFTS a LEFT JOIN algo_price b USING(day)
    Run a query to Download Data