with flow as (
select avg(price_usd) as flow_price
from flow.core.fact_prices
)
select split_part(nft_collection, '.', 3) as collection, sum(iff(SPLIT_PART(CURRENCY, '.', 3) = 'FlowToken', price * flow_price, price)) as usd_volume
from flow.core.fact_nft_sales, flow
where tx_succeeded = 1
group by 1