flyingfishGet data from previous query
Updated 2024-10-14
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
›
⌄
⌄
⌄
/*
The query id can be taken from the browser address bar when editing your target query
*/
with get_base_query AS (
-- Get data from target query
SELECT
value:DAY::date as day
, value:CHAIN::string AS chain
, value:ACTIONS::numeric AS actions
FROM (
SELECT
livequery.live.udf_api('https://flipsidecrypto.xyz/api/v1/queries/21c0b433-117d-4c10-b999-43da83f9ea66/data/latest') as response
), lateral FLATTEN (input => response:data)
)
-- Calc a few stats
SELECT
sum(actions) AS weekly_actions
, max(actions) AS most_active_day_actions
FROM get_base_query
/*
Alternative way using the column index
Downside to this method, is that it will need a rewrite in case column order is changed
value[0]::date as day
, value[1]::string AS chain
, value[2]::numeric AS actions
*/
QueryRunArchived: QueryRun has been archived