boomer77Untitled Query
Updated 2021-12-22
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 register as (select tx_from_address, count(distinct event_inputs:id) as register_domain
from ethereum.events_emitted
where contract_address='0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85' and
event_name = 'NameRegistered' and tx_succeeded = 'TRUE'
group by 1),
sale as (select event_from, count(distinct token_id) as sale
from ethereum.nft_events
where contract_address = '0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85' and event_type = 'sale'
group by 1),
buy as (select event_to, count(distinct token_id) as buy
from ethereum.nft_events
where contract_address = '0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85' and event_type = 'sale'
group by 1),
register_sold as (select a.tx_from_address, b.sale, case when b.sale is null then 0 else b.sale end as sales, (a.register_domain - sales) as domains_owned
from register a
left outer join sale b on a.tx_from_address = b.event_from),
register_buy as (select a.tx_from_address, (a.domains_owned + b.buy) as domain_owned, case
when domain_owned = 1 then 'One_Domain_owned'
else 'Multiple_domains' end as own
from register_sold a
left outer join buy b on a.tx_from_address = b.event_to)
select own, count(tx_from_address)
from register_buy
where domain_owned is not NULL
group by 1
Run a query to Download Data