SELECT
*,
sum(volume) over (order by date) as cum_vol,
avg(average_price) over (order by date) as cum_avg
FROM (
SELECT
BLOCK_TIMESTAMP::date as date,
COUNT(*) as sales_count,
avg(PRICE) as average_price,
sum(price) as volume
FROM flow.core.fact_nft_sales
WHERE NFT_COLLECTION ilike 'A.0b2a3299cc857e29.TopShot'
GROUP BY 1
)
order by date desc