Sbhn_NPUntitled Query
Updated 2023-03-03
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
›
⌄
with base as (
SELECT
date_trunc('month', block_timestamp) as month,
sum(case WHEN symbol_in LIKE 'USDC' then amount_in_usd ELSE 0 end) as sell_volume,
sum(case WHEN symbol_out LIKE 'USDC' then amount_out_usd ELSE 0 end) as buy_volume,
sum(case WHEN symbol_out LIKE 'USDC' then amount_out_usd ELSE 0 end) - sum(case WHEN symbol_in LIKE 'USDC' then amount_in_usd ELSE 0 end) as net_buy_volume
FROM ethereum.core.ez_dex_swaps
WHERE symbol_in LIKE 'USDC'
OR symbol_out LIKE 'USDC'
GROUP BY 1
)
SELECT
*,
sum(net_buy_volume) over (ORDER BY month) as cume_buy_volume
FROM base
Run a query to Download Data