h4wkRAY price
    Updated 2024-12-12
    -- forked from blze @ https://flipsidecrypto.xyz/edit/queries/2571b641-f0ec-4e1f-b2a5-a4400d680645

    with price as (
    select date_trunc('week', hour::date) as price_date,
    upper(symbol) as symbol,
    avg(price) as price
    from solana.price.ez_prices_hourly
    where upper(symbol) ilike 'RAY'
    group by 1,2
    )

    , diff AS (
    SELECT
    date_trunc('week', price_date) as price_date_month,
    price,
    LAG(price) OVER (ORDER BY price_date_month) AS prev_month_value,
    (price - LAG(price) OVER
    (ORDER BY price_date_month)) / LAG(price)
    OVER (ORDER BY price_date_month) AS percentage_diff
    FROM
    price
    where symbol = 'RAY'
    )
    SELECT
    price_date_month,
    price as "RAY Price",
    zeroifnull(percentage_diff*100) as DoD_percentage,
    case when DoD_percentage < 0 then 'WoW Neg (%)'
    else 'WoW Pos (%)' end as wow_type
    FROM
    diff
    WHERE
    -- prev_month_value IS NOT NULL
    price_date_month >= '2023-01-01'
    ORDER BY
    price_date_month DESC;
    Auto-refreshes every 24 hours
    QueryRunArchived: QueryRun has been archived