select
platform_name as market_place,
project_name,
count(distinct(tx_hash)) as sales_count,
sum(price_usd) as volume_usd,
avg(price_usd) as volume_avg,
median(price_usd) as volume_median,
count(distinct(buyer_address)) as purchasers_count,
(sales_count / purchasers_count) as tx_per_purchaser,
(volume_usd / purchasers_count) as volume_per_purchaser,
count(distinct(seller_address)) as sellers_count,
(sales_count / sellers_count) as tx_per_seller,
(volume_usd / sellers_count) as volume_per_seller,
row_number() over (partition by market_place order by volume_usd desc) as rank
from ethereum.core.ez_nft_sales
where block_timestamp >= '2022-11-01'
and project_name is not null
group by market_place, project_name
having volume_usd > 0
qualify rank <= 5
order by 1, rank