MadiUntitled Query
Updated 2022-10-29Copy 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
›
⌄
with df_purchase as (select block_timestamp as purchase_date,
event_inputs:_to as buyer_address,
event_inputs:_id as tokenid
from polygon.core.fact_event_logs
where tx_status = 'SUCCESS' and block_timestamp >= '2022-08-26' and event_name = 'TransferSingle' and event_inputs:_from != '0x0000000000000000000000000000000000000000'
and contract_address = lower('0x8d0501d85becda92b89e56177ddfcea5fc1f0af2') and buyer_address != '0x83bfa75c9391dbe19e0a1d2c53c9b6c4baef5ab7' and buyer_address != '0x0000a26b00c1f0df003000390027140000faa719'),
df_sold as (select block_timestamp as sold_date,
event_inputs:_from as seller_address,
b.event_inputs:_id as tokenid
from df_purchase a
join polygon.core.fact_event_logs b on a.buyer_address = b.event_inputs:_from and a.tokenid = b.event_inputs:_id
where b.block_timestamp > purchase_date),
df as (select datediff(day, purchase_date, sold_date) as hold_time,
1 as count
from df_purchase a
join df_sold b on a.buyer_address = b.seller_address and a.tokenid = b.tokenid)
select case
when hold_time < 1 then 'Less than 1 day'
when hold_time > 1 and hold_time <= 7 then '1-7 days'
when hold_time > 7 and hold_time <= 14 then '7-14 days'
when hold_time > 14 and hold_time <= 30 then '14-30 days'
else 'More then 30 days'
end as duration,
sum(count) as count
from df
group by 1
order by 1
Run a query to Download Data