suchanad2024-05-23 01:52 PM
Updated 2024-05-24
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 inflows AS (
SELECT
date_trunc('day', BLOCK_TIMESTAMP) AS "Trans_Date",
PUBKEY_SCRIPT_ADDRESS AS "Address",
SUM(VALUE) AS "Daily Inflows"
FROM bitcoin.core.fact_outputs;
WHERE date_trunc('day', BLOCK_TIMESTAMP) >= '2024-05-12'
AND date_trunc('day', BLOCK_TIMESTAMP) <= '2024-05-18'
GROUP BY date_trunc('day', BLOCK_TIMESTAMP),
PUBKEY_SCRIPT_ADDRESS
),
outflows AS (
SELECT
date_trunc('day', BLOCK_TIMESTAMP) AS "Trans_Date",
PUBKEY_SCRIPT_ADDRESS AS "Address",
SUM(VALUE) AS "Daily Outflows"
FROM bitcoin.core.fact_inputs
WHERE date_trunc('day', BLOCK_TIMESTAMP) >= '2024-05-12'
AND date_trunc('day', BLOCK_TIMESTAMP) <= '2024-05-18'
GROUP BY date_trunc('day', BLOCK_TIMESTAMP),
PUBKEY_SCRIPT_ADDRESS
),
balances AS (
SELECT
inflows."Trans_Date",
inflows."Address",
COALESCE(inflows."Daily Inflows", 0) - COALESCE(outflows."Daily Outflows", 0) AS "Net Daily Balance"
FROM inflows
FULL OUTER JOIN outflows
ON inflows."Trans_Date" = outflows."Trans_Date"
AND inflows."Address" = outflows."Address"
),
wallets AS (
SELECT
"Address",
"Net Daily Balance",
QueryRunArchived: QueryRun has been archived