TheLaughingManQuarterly Comparisons Strings+Emojis
    Updated 2025-02-11
    -- forked from Quarterly Comparisons @ https://flipsidecrypto.xyz/studio/queries/a281ac54-d871-4f7f-8163-7a5460149da8

    with ranges as (
    SELECT
    TO_TIMESTAMP_NTZ('{{start_date}}') as start_date
    , 4 as quarters
    UNION ALL
    SELECT
    DATEADD('month', -3, start_date), quarters-1
    from ranges
    WHERE
    quarters>1
    )

    , q1_data as (
    with q1_merge as (
    ---arbitrum
    SELECT * EXCLUDE version, 'arbitrum' as label from arbitrum.vertex.ez_perp_trades
    LEFT JOIN (SELECT * from ranges WHERE quarters=1)
    WHERE 1=1
    AND ( block_timestamp::date >= start_date AND DATEDIFF('month', start_date, block_timestamp::date) BETWEEN 0 and 2)
    AND trader != '0x0000000000000000000000000000000000000000'
    AND subaccount!='0x0000000000000000000000000000000000000000000000000000000000000001'
    UNION ALL
    ---base
    SELECT *, 'base' as label from base.vertex.ez_perp_trades
    LEFT JOIN (SELECT * from ranges WHERE quarters=1)
    WHERE 1=1
    AND ( block_timestamp::date >= start_date AND DATEDIFF('month', start_date, block_timestamp::date) BETWEEN 0 and 2)
    AND trader != '0x0000000000000000000000000000000000000000'
    AND subaccount!='0x0000000000000000000000000000000000000000000000000000000000000001'
    UNION ALL
    QueryRunArchived: QueryRun has been archived