with purchasert as (
select
block_timestamp,
purchaser,
mint,
sales_amount
from solana.core.fact_nft_sales
where block_timestamp::date >='2022-01-01'
),
sellert as (
select
block_timestamp,
Seller,
mint,
sales_amount
from solana.core.fact_nft_sales
where block_timestamp::date >='2022-01-01'
),
finalt as (
select
p.block_timestamp as buydate,
s.block_timestamp as selldate,
purchaser,
s.sales_amount - p.sales_amount as net_profit_volume
from purchasert p join sellert s on purchaser = seller and p.mint = s.mint
where p.sales_amount is not null
and s.sales_amount is not null) ,
top_traders as (
select
--p.block_timestamp as date,
purchaser,
sum(net_profit_volume) as net_profit_volume
from finalt