feyikemiFlow Txns % diff
Updated 2024-08-03
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
›
⌄
WITH Txns_July AS (
SELECT
DATE_TRUNC('month', block_timestamp) AS month,
COUNT(DISTINCT Tx_id) AS Txns
FROM
flow.core.fact_transactions
WHERE
block_timestamp::DATE >= '2024-01-01'
AND block_timestamp::DATE < '2024-08-01'
AND Tx_succeeded = 'True'
GROUP BY 1
)
SELECT
Month,
Txns,
LAG(Txns) OVER (ORDER BY Month) AS Previous_month_users,
IFF(
((Txns - LAG(Txns) OVER (ORDER BY Month)) / LAG(Txns) OVER (ORDER BY Month)) * 100 < 0,
0,
((Txns - LAG(Txns) OVER (ORDER BY Month)) / LAG(Txns) OVER (ORDER BY Month)) * 100
) AS Txns_diff
--((Txns - LAG(Txns) OVER (ORDER BY Month)) / LAG(Txns) OVER (ORDER BY Month)) *100 AS Txns_diff
FROM Txns_July
ORDER BY Month DESC
QueryRunArchived: QueryRun has been archived