OwentellDo Whales Have Diamond Hands? (3)
Updated 2022-06-22Copy 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
›
⌄
WITH whales AS (
SELECT trader as whale, count(DISTINCT tx_id) as num_swaps
FROM osmosis.core.fact_swaps
WHERE block_timestamp BETWEEN current_date - 62 AND current_date - 2
GROUP BY whale
HAVING num_swaps > 1000
),
trunc AS (
SELECT DATE_TRUNC('DAY', block_timestamp) as day, project_name,
COUNT(DISTINCT tx_id) as num_swaps
FROM osmosis.core.fact_swaps
LEFT JOIN osmosis.core.dim_labels on address = from_currency
WHERE trader NOT IN (select whale from whales )
AND block_timestamp BETWEEN current_date - 62 AND current_date - 2
GROUP BY day, project_name
),
rank AS (
SELECT day, project_name, num_swaps,
RANK() OVER(PARTITION BY day ORDER BY num_swaps DESC) as rank
FROM trunc
)
SELECT *
FROM rank
WHERE rank <= 5
Run a query to Download Data