j-hackworthPolygon_stats
Updated 2022-07-14Copy 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 MATIC as (SELECT
DATE(block_timestamp) as "Date",
COUNT(tx_hash) as "# of Transactions - Matic",
percentile_cont(.1) within GROUP (ORDER BY tx_fee) as ".1 Percentile of TX Fees",
percentile_cont(.9) within GROUP (ORDER BY tx_fee) as ".9 Percentile of TX Fees",
AVG(tx_fee) as "AVG Transaction Fee",
AVG("Price") as "AVG Matic Price",
AVG(tx_fee * "Price") as "AVG Transaction Fee ($USD)",
SUM(tx_fee) as "Total Fees Per Day",
SUM(tx_fee * "Price") as "Total Fees Per Day ($USD)",
SUM(SUM(tx_fee)) OVER (ORDER BY DATE(block_timestamp)) as "Cumulative Transaction Fees",
SUM(COUNT(tx_fee)) OVER (ORDER BY DATE(block_timestamp)) as "Cumulative Transactions - Matic",
SUM(SUM(tx_fee * "Price")) OVER (ORDER BY DATE(block_timestamp)) as "Cumulative Transaction Fees ($USD)"
FROM polygon.core.fact_transactions t
LEFT JOIN (SELECT DATE(hour) as "D",
AVG(price) as "Price" FROM ethereum.core.fact_hourly_token_prices WHERE symbol = 'MATIC' GROUP BY DATE(hour)) a ON a."D" = DATE(block_timestamp)
WHERE DATE(block_timestamp) >= '2022-01-01'
GROUP BY DATE(block_timestamp)
ORDER BY DATE(block_timestamp) DESC),
active as (SELECT
"Date",
COUNT(DISTINCT("Address")) as "# of Active Users",
AVG(COUNT(DISTINCT("Address"))) OVER (ORDER BY "Date") as "Running Average Active Users"
FROM (
SELECT
DATE(block_timestamp) as "Date",
from_address as "Address"
FROM polygon.core.fact_transactions t
WHERE DATE(block_timestamp) >= '2022-01-01'
UNION ALL
SELECT
DATE(block_Timestamp) as "Date",
Run a query to Download Data