mondov2023-06-05 09:31 PM
    Updated 2023-06-05
    WITH deposit_categories AS (
    SELECT
    CASE
    WHEN total_deposited < 10 THEN '< $10'
    WHEN total_deposited >= 10 AND total_deposited < 100 THEN '$10-$100'
    WHEN total_deposited >= 100 AND total_deposited < 1000 THEN '$100-$1,000'
    WHEN total_deposited >= 1000 AND total_deposited < 10000 THEN '$1,000-$10,000'
    WHEN total_deposited >= 10000 AND total_deposited < 100000 THEN '$10,000-$100,000'
    ELSE '$100,000+'
    END AS deposit_category,
    COUNT(DISTINCT DEPOSITOR_ADDRESS) AS num_depositors
    FROM (
    SELECT
    DEPOSITOR_ADDRESS,
    SUM(SUPPLIED_USD) AS total_deposited
    FROM ethereum.aave.ez_deposits
    WHERE AAVE_MARKET = '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9'
    AND BLOCK_TIMESTAMP >= CURRENT_DATE - {{past_days}}
    GROUP BY DEPOSITOR_ADDRESS
    ) AS subquery
    GROUP BY deposit_category
    )

    SELECT *
    FROM deposit_categories
    Run a query to Download Data