feyikemiNear report 4 copy
    Updated 2024-07-22
    -- forked from adriaparcerisas / Near report 4 @ https://flipsidecrypto.xyz/adriaparcerisas/q/iEboWYFFFQpT/near-report-4

    WITH
    near as (
    Select
    trunc(block_timestamp,'hour') as date,
    count(distinct tx_hash) as txs,
    txs/1440 as tpm
    From near.core.fact_transactions
    Where block_timestamp::date >=current_date - INTERVAL '1 WEEK'
    Group by 1
    order by 1 ASC
    ),
    near_fail as (
    Select
    trunc(block_timestamp,'hour') as date,
    count(distinct tx_hash) as failed_txs
    From near.core.fact_transactions
    Where block_timestamp::date >=CURRENT_DATE - INTERVAL '1 WEEK'
    and tx_succeeded<>TRUE
    Group by date
    order by date ASC
    ),
    hourly as (
    SELECT
    x.date,
    txs,
    failed_txs,
    txs-failed_txs as succeeded_txs,
    (failed_txs/txs)*100 as pcg_failed,
    (succeeded_txs/txs)*100 as pcg_succeeded
    from near x, near_fail y where x.date=y.date
    ),
    near2 as (
    Select
    trunc(block_timestamp,'day') as date,
    QueryRunArchived: QueryRun has been archived