Pine Analyticsens 1
Updated 2024-07-02
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
›
⌄
WITH tab1 as (
SELECT --*
tx_hash,
BLOCK_TIMESTAMP,
decoded_log:name as name,
decoded_log:owner owner,
CASE when decoded_log:cost is NULL then decoded_log:baseCost else decoded_log:cost end / power(10, 18) as cost_eth
FROM ethereum.core.ez_decoded_event_logs
where event_name like 'NameRegistered'
AND contract_address IN (lower('0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5'), lower('0x253553366Da8546fC250F225fe3d25d0C782303b'))
ORDER BY block_timestamp DESC
)
SELECT
date_trunc('week', block_timestamp) as week,
count(DISTINCT owner) as registrant,
count(*) as events,
sum(cost_eth) as fee_eth,
sum(cost_eth * price) as fee_USD
FROM tab1 as a
LEFT outer JOIN (
SELECT
date_trunc('week', hour) as week1,
median(price) as price
FROM ethereum.price.ez_prices_hourly
where token_address LIKE lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
GROUP BY 1
) as b
on week1 = date_trunc('week', block_timestamp)
GROUP BY 1
QueryRunArchived: QueryRun has been archived