andurilInstructions per Transaction copy
    Updated 2023-05-11
    -- forked from nundox / Instructions per Transaction @ https://flipsidecrypto.xyz/nundox/q/2023-05-03-02-10-pm-4sF_qm

    with
    inner_ix_ct as (
    select
    e.tx_id,
    e.instruction:programId as programId,
    COUNT(vm.value) as inner_ix_ct,
    0 as ix_ct
    from
    solana.core.fact_events as e,
    LATERAL FLATTEN(INPUT => inner_instruction:instructions) as vm
    where
    succeeded
    and block_timestamp > '2023-05-01 00:00:00.000'
    and program_id = '3Kr1RcL41pWL7qzAA5tCTTKcqjbG3RNRsFaDGMd82iW4'
    group by
    e.tx_id, programId
    ),
    ix_ct as (
    select
    tx_id,
    instruction:programId as programId,
    0 as inner_ix_ct,
    COUNT(*) as ix_ct
    from
    solana.core.fact_events
    where
    succeeded
    and block_timestamp > '2023-05-01 00:00:00.000'
    group by
    tx_id, programId
    )
    select
    ii.tx_id,
    ii.programId,
    Run a query to Download Data