Moe tp.sht hold duration- playtype
Updated 2022-10-13Copy Reference Fork
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
32
33
34
35
36
›
⌄
with buy as (select
block_timestamp,s.nft_id,buyer,seller,play_type from
flow.core.fact_nft_sales s
join flow.core.dim_topshot_metadata m on s.NFT_ID = m.NFT_ID
where
s.NFT_COLLECTION = 'A.0b2a3299cc857e29.TopShot'
and currency = 'A.ead892083b3e2c6c.DapperUtilityCoin' and TX_SUCCEEDED = 'TRUE'
)
,sell as (select
block_timestamp,s.nft_id,buyer,seller,play_type from
flow.core.fact_nft_sales s
join flow.core.dim_topshot_metadata m on s.NFT_ID = m.NFT_ID
where
s.NFT_COLLECTION = 'A.0b2a3299cc857e29.TopShot'
and currency = 'A.ead892083b3e2c6c.DapperUtilityCoin' and TX_SUCCEEDED = 'TRUE'
)
,base as (
select
b.*,s.BLOCK_TIMESTAMP as sBLOCK_TIMESTAMP
from
buy b join sell s on b.buyer = s.seller
and s.BLOCK_TIMESTAMP > b.BLOCK_TIMESTAMP
),
fin as (select
NFT_ID,buyer ,play_type,BLOCK_TIMESTAMP as purchase_time,
sBLOCK_TIMESTAMP as selling_time,datediff(day,purchase_time,selling_time) as duration_hours
from base)
select
play_type ,
avg(duration_hours) as avg_hold_days,
row_number()over(order by avg_hold_days desc) as n
from fin
Run a query to Download Data