StangFAST003 - growth
    Updated 2024-05-27
    -- forked from 002 - defi @ https://flipsidecrypto.xyz/edit/queries/f9461525-b925-410a-bdfa-7dcf6ab463ba

    -- forked from overview @ https://flipsidecrypto.xyz/edit/queries/8b459c15-4875-436f-bbc2-bb836742a105

    with

    price AS
    (
    SELECT
    date_trunc( 'day' , a.recorded_hour ) AS date
    , avg( a.close ) AS price
    , a.symbol AS token
    FROM
    solana.price.ez_token_prices_hourly a
    WHERE
    a.symbol = 'sol'
    GROUP BY 1 , 3
    ORDER BY 1 DESC
    )

    SELECT

    date_trunc( '{{period}}' , a.block_timestamp ) AS "date"

    , count( DISTINCT a.signers ) AS "users"

    , lag( "users" , 1 ) over ( ORDER BY "date" ASC ) AS "lags"
    , "users" - "lags" AS "change"
    , round( ( "change" / "lags" ) * 100 , 2 ) AS "growth"
    , case when "growth" < 0 then 'Decrease ( % )' else 'Increase ( % ) ' end AS " Growth "


    FROM
    solana.core.fact_events a

    QueryRunArchived: QueryRun has been archived