feyikemiFlow Txns % diff
    Updated 2024-08-03
    WITH Txns_July AS (
    SELECT
    DATE_TRUNC('month', block_timestamp) AS month,
    COUNT(DISTINCT Tx_id) AS Txns
    FROM
    flow.core.fact_transactions
    WHERE
    block_timestamp::DATE >= '2024-01-01'
    AND block_timestamp::DATE < '2024-08-01'
    AND Tx_succeeded = 'True'
    GROUP BY 1
    )

    SELECT
    Month,
    Txns,
    LAG(Txns) OVER (ORDER BY Month) AS Previous_month_users,
    IFF(
    ((Txns - LAG(Txns) OVER (ORDER BY Month)) / LAG(Txns) OVER (ORDER BY Month)) * 100 < 0,
    0,
    ((Txns - LAG(Txns) OVER (ORDER BY Month)) / LAG(Txns) OVER (ORDER BY Month)) * 100
    ) AS Txns_diff
    --((Txns - LAG(Txns) OVER (ORDER BY Month)) / LAG(Txns) OVER (ORDER BY Month)) *100 AS Txns_diff

    FROM Txns_July
    ORDER BY Month DESC
    QueryRunArchived: QueryRun has been archived