with flow_price 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
),
main1 as (
select
block_timestamp::date as date,
sum(price) as price
from flow.core.fact_nft_sales
where NFT_COLLECTION ='A.e4cf4bdc1751c65d.PackNFT'
or NFT_COLLECTION = 'A.e4cf4bdc1751c65d.AllDay'
group by 1
),
main2 as (
select
fl.fp_date,
fl.flow_price,
main1.price,
price*flow_price as NFT_price_USD
from flow_price fl
join main1 main1
on fl.fp_date=main1.date
)
select *
from main2