TheLaughingManQuarterly Comparisons Optimized (+ instance param) copy
    Updated 2025-02-13
    -- forked from Quarterly Comparisons Optimized (+ instance param) @ https://flipsidecrypto.xyz/studio/queries/095d8b87-145b-4c65-a90d-342b80270baf

    -- forked from Quarterly Comparisons Optimized (EDGE Excluded) @ https://flipsidecrypto.xyz/studio/queries/0527b0dc-7cba-4b3e-9507-57f43d07bcf8

    -- forked from Quarterly Comparisons Strings+Emojis Optimized (EDGE included) @ https://flipsidecrypto.xyz/studio/queries/ef7b409d-a864-4e78-9961-bc7392a1814f

    with trades_data as (

    SELECT * EXCLUDE version, 'arbitrum' as label from arbitrum.vertex.ez_perp_trades
    WHERE 1=1
    AND (DATEDIFF('month', '{{start_date}}', block_timestamp::date) BETWEEN -9 and 2)
    -- AND (
    -- ( -- ignore EDGE if all instances being tallied & avoid double counting...
    -- 'all' = lower('{{instance_quarters}}')
    -- AND trader != '0x0000000000000000000000000000000000000000'
    -- AND subaccount!='0x0000000000000000000000000000000000000000000000000000000000000001'
    -- )
    -- OR
    -- ( -- individual instance, no need to filter EDGE
    -- label = lower('{{instance_quarters}}')
    -- )
    -- )
    UNION ALL
    ---base
    SELECT *, 'base' as label from base.vertex.ez_perp_trades
    WHERE 1=1
    AND (DATEDIFF('month', '{{start_date}}', block_timestamp::date) BETWEEN -9 and 2)
    -- AND (
    -- ( -- ignore EDGE if all instances being tallied & avoid double counting...
    -- 'all' = lower('{{instance_quarters}}')
    -- AND trader != '0x0000000000000000000000000000000000000000'
    -- AND subaccount!='0x0000000000000000000000000000000000000000000000000000000000000001'
    -- )
    -- OR
    -- ( -- individual instance, no need to filter EDGE
    -- label = lower('{{instance_quarters}}')
    QueryRunArchived: QueryRun has been archived