with unique_wallets as (
select date_trunc('day', block_timestamp) as date, buyer as traders
from flow.core.fact_nft_sales
where block_timestamp::date >= '2022-05-09' and marketplace in ('A.c1e4f4f4c4257510.TopShotMarketV3', 'A.c1e4f4f4c4257510.Market') and tx_succeeded = true
union all
select date_trunc('day', block_timestamp) as date, seller as traders
from flow.core.fact_nft_sales
where block_timestamp::date >= '2022-05-09' and marketplace in ('A.c1e4f4f4c4257510.TopShotMarketV3', 'A.c1e4f4f4c4257510.Market') and tx_succeeded = true
),
wallets_count as (
select date as date1, count(distinct traders) as unique_wallets
from unique_wallets
group by 1
),
sales_volume as (
select date_trunc('day', block_timestamp) as date, sum(price) as sales_volume
from flow.core.fact_nft_sales
where date >= '2022-05-09' and marketplace in ('A.c1e4f4f4c4257510.TopShotMarketV3', 'A.c1e4f4f4c4257510.Market') and tx_succeeded = true
group by 1
)
select date, sales_volume, unique_wallets
from wallets_count, sales_volume
where date = date1