ThatGuyOptimism - User Behavior 1. agg
    Updated 2022-10-25
    WITH
    opt as (
    SELECT
    DATE_TRUNC('week',block_timestamp) as week,
    DATE_TRUNC('day',block_timestamp) as date,
    COUNT(DISTINCT FROM_ADDRESS) as "OP User Count",
    COUNT(DISTINCT tx_hash) as "OP TX Count",
    SUM(TX_FEE) as "OP Fees (in ETH)",
    SUM("OP Fees (in ETH)") over (ORDER by date) as "OP Cumulative Fees (in ETH)"
    FROM optimism.core.fact_transactions
    WHERE
    STATUS = 'SUCCESS'
    GROUP BY 1,2
    ORDER BY 1,2
    )
    ,
    eth as (
    SELECT
    DATE_TRUNC('day',block_timestamp) as date,
    DATE_TRUNC('week',block_timestamp) as week,
    COUNT(DISTINCT FROM_ADDRESS) as "ETH User Count",
    COUNT(DISTINCT tx_hash) as "ETH TX Count",
    SUM(TX_FEE) as "ETH Fees (in ETH)",
    SUM("ETH Fees (in ETH)") over (ORDER by date) as "ETH Cumulative Fees (in ETH)"
    FROM ethereum.core.fact_transactions
    WHERE
    STATUS = 'SUCCESS'
    GROUP BY 1,2
    ORDER BY 1,2
    )
    , detail as (
    SELECT
    *,
    (("ETH User Count" - "OP User Count") / "OP User Count") * 100 as "% User Ratio",
    (("ETH TX Count" - "OP TX Count") / "OP TX Count") * 100 as "% TX Count Ratio",
    (("ETH Fees (in ETH)" - "OP Fees (in ETH)") / "OP Fees (in ETH)") * 100 as "% Fees Ratio"
    Run a query to Download Data