flyingfishGet data from previous query
    Updated 2024-10-14
    /*
    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