datavortexdistribution
    Updated 2024-12-17
    WITH platform_totals AS (
    SELECT
    platform,
    COUNT(DISTINCT origin_from_address) AS total_users,
    COUNT(DISTINCT tx_hash) AS total_swaps,
    SUM(amount_in_usd) AS total_volume_usd
    FROM
    kaia.defi.ez_dex_swaps
    GROUP BY
    platform
    ),
    overall_totals AS (
    SELECT
    SUM(total_users) AS overall_total_users,
    SUM(total_swaps) AS overall_total_swaps,
    SUM(total_volume_usd) AS overall_total_volume_usd
    FROM
    platform_totals
    ),
    capybara_totals AS (
    SELECT
    total_users AS capybara_users,
    total_swaps AS capybara_swaps,
    total_volume_usd AS capybara_volume_usd
    FROM
    platform_totals
    WHERE
    platform = 'capybara'
    )
    SELECT
    t.overall_total_users AS total_users_all_platforms,
    c.capybara_users AS total_capybara_users,
    ROUND(
    c.capybara_users * 100.0 / NULLIF(t.overall_total_users, 0),
    2
    ) AS user_percentage,
    QueryRunArchived: QueryRun has been archived