with flow_prices as (
select
timestamp::date as fp_date,
avg(price_usd) as flow_price
from flow.core.fact_prices
where symbol = 'FLOW'
and asset_id = 'flow'
group by 1
)
select t2.CONTRACT_NAME as "NFT project",sum(price * p.flow_price) as "Total Sales Volume (USD)"
from flow.core.fact_nft_sales as ns join flow_prices p
on ns.block_timestamp::date = p.fp_date
join flow.core.dim_contract_labels as t2
on ns.NFT_COLLECTION=t2.EVENT_CONTRACT
where tx_succeeded = 'TRUE'
group by t2.CONTRACT_NAME
order by "Total Sales Volume (USD)" desc
limit 10