Hessish9.5 txs < 20
    Updated 2023-09-06
    -- forked from 9.4 AVG_TX_PER_USER @ https://flipsidecrypto.xyz/edit/queries/9bb72e36-a844-4768-ac43-beae10c246f9

    with accs as
    (SELECT distinct CONTRACT as user, case when
    CLASS_HASH = '0x03530cc4759d78042f1b543bf797f5f3d647cde0388c33734cf91b7f7b9314a9' then 'Okex'
    When CLASS_HASH = '0x058d97f7d76e78f44905cc30cb65b91ea49a4b908a76703c54197bca90f81773' then 'bitstamp'
    When CLASS_HASH = '0x025ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918' then 'argentx'
    When CLASS_HASH = '0x03131fa018d520a037686ce3efddeab8f28895662f019ca3ca18a626650f7d1e' then 'braavos' else 'other' end as provider
    from external.tokenflow_starknet.decoded_transactions
    where
    type like '%DEPLOY%' and CHAIN_ID = 'mainnet'
    ),

    t1 as (SELECT DISTINCT contract as wlts, count(DISTINCT tx_hash) as txs
    from external.tokenflow_starknet.decoded_transactions
    where CHAIN_ID = 'mainnet'
    GROUP by 1
    having txs < 21

    )

    SELECT count(DISTINCT tx_hash)/count(DISTINCT user) as avg_tx_per_user, provider , count(DISTINCT user) as total_users, count(DISTINCT tx_hash) as total_txs
    from external.tokenflow_starknet.decoded_transactions join accs on user=contract
    where
    CHAIN_ID = 'mainnet'
    and contract in (SELECT DISTINCT wlts from t1)
    GROUP by 2
    order by 3 desc


    Run a query to Download Data