MLDZMNffuser2
    Updated 2023-06-10
    with tb1 as (select
    distinct signers[0] as users,
    count(distinct s.tx_id) as no_txn

    from solana.core.fact_transactions s
    left join solana.core.fact_transfers a on s.tx_id=a.tx_id
    where array_contains('Program log: Instruction: CompleteSwap'::variant, log_messages)
    and INSTRUCTIONS[0]:programId= '8guzmt92HbM7yQ69UJg564hRRX6N4nCdxWE5L6ENrA8P'
    and MINT in ('So11111111111111111111111111111111111111112')
    and (INNER_INSTRUCTIONS[1]:instructions[0]:parsed:info:destination = tx_to or
    tx_from = INNER_INSTRUCTIONS[1]:instructions[0]:parsed:info:destination )
    and s.BLOCK_TIMESTAMP>=current_date-{{Days_back}}
    and SUCCEEDED='TRUE'
    group by 1
    )

    select
    case
    when no_txn=1 then 'a. 1 time purchaser'
    when no_txn> 1 and 3 then 'b. 1-3 times purchaser'
    when no_txn between 3 and 5 then 'c. 3-5 times purchaser'
    when no_txn>=5 then 'd. more then 5 times purchaser'
    end as gp,
    count(distinct users) as no_wl
    from tb1
    group by 1
    Run a query to Download Data