Abolfazl_771025top 10 holder by volume (Flow)
Updated 2022-11-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
31
32
33
34
35
36
›
⌄
with flow_in as (select
event_data:to as user,
sum(event_data:amount) as "volume in (Flow)"
from flow.core.fact_events
where event_type = 'TokensDeposited'
and tx_succeeded = 'TRUE'
and event_contract = 'A.1654653399040a61.FlowToken'
and block_timestamp >= '2022-01-01'
group by 1
),flow_out as (select
event_data:from as user,
sum(event_data:amount) as "volume out (Flow)"
from flow.core.fact_events
where event_type = 'TokensWithdrawn'
and tx_succeeded = 'TRUE'
and event_contract = 'A.1654653399040a61.FlowToken'
and block_timestamp >= '2022-01-01'
group by 1
) , main as(select
DISTINCT a.user as holders,
sum("volume in (Flow)" - "volume out (Flow)") as "volume of flow that hold"
from flow_in a join flow_out b on a.user = b.user
full outer join flow.core.dim_contract_labels c on a.user = c.account_address
where a.user is not null
and a.user != 'null'
group by 1)
select
rank() over (order by "volume of flow that hold" desc) as rank,
case
when rank<11 then concat(rank,'-',holders)
else concat('10',rank,'-',holders)
end as "holders",
"volume of flow that hold"
from main
order by 3 desc
limit 10
Run a query to Download Data