CartanGroupAptos Base - [chain] Transactions by Type
    Updated 2024-06-27
    with

    txs as (

    select

    block_timestamp
    , block_number
    , count(case when tx_type = 'user_transaction' then 1 end) as user_txs
    , count(case when tx_type = 'state_checkpoint_transaction' then 1 end) as checkpoint_txs
    , count(case when tx_type = 'block_metadata_transaction' then 1 end) as metadata_txs
    , user_txs + checkpoint_txs + metadata_txs as transactions

    from aptos.core.fact_transactions
    where block_timestamp > '2022-11-01'
    group by 1,2
    )
    select date,
    avg("User Transactions") over (order by date rows between 7 preceding and current row) as "User Transactions",
    avg("State Checkpoint Txs.") over (order by date rows between 7 preceding and current row) as "State Checkpoint Txs.",
    avg("Block Metadata Txs.") over (order by date rows between 7 preceding and current row) as "Block Metadata Txs."
    FROM (
    select

    date_trunc('{{date_trunc}}', block_timestamp) as date
    , sum(user_txs) as "User Transactions"
    , sum(checkpoint_txs) as "State Checkpoint Txs."
    , sum(metadata_txs) as "Block Metadata Txs."

    from txs
    group by 1
    )a
    order by 1 desc


    QueryRunArchived: QueryRun has been archived