yasmin-n-d-r-h2023-10-10 03:02 PM
Updated 2023-10-14
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
›
⌄
with nft_sales as (select *from flow.nft.ez_nft_sales where NFT_collection like '%Barbie%'),
tab_Buyer as (select block_timestamp, buyer,
nft_id, price as Buy_Price from nft_sales) ,
tab_seller as (select block_timestamp, seller,
nft_id,
price as Sell_Price
from nft_sales
)
, tab0 as (
SELECT
buyer,
sum(sell_Price) - sum(buy_price) as Net_Profit
from tab_buyer a left outer join tab_seller b on buyer = seller and a.nft_id = b.nft_id
group by 1
having net_profit is not null
order by 2 DESC
limit 10
)
SELECT
'stat'as status,
sum(sell_price - buy_price) as "Total Profit" ,
count(case when sell_price - buy_price > 0 then 1 end) as "gain",
count(case when sell_price - buy_price < 0 then 1 end) as "loss"
from tab_buyer a left outer join tab_seller b on buyer = seller and a.nft_id = b.nft_id
where buyer in (select buyer from tab0)
Run a query to Download Data