anomoneSomeone's CTE for Luna wallets
    WITH balance AS (
    SELECT
    date,
    address,
    sum (balance_usd) as total_balance
    FROM terra.daily_balances
    WHERE date > getdate() - interval '1 month'
    GROUP BY 1,2
    ),
    address_class as(
    SELECT
    date,
    address,
    CASE
    WHEN total_balance >= 100000 THEN 'Large Wallet'
    ELSE 'Smaller Wallet'
    END AS address_tag,
    total_balance
    FROM balance
    )

    SELECT
    date_trunc('day', s.block_timestamp) as date,
    a.address_tag,
    count(DISTINCT s.tx_id) as tx_count
    FROM terra.transfers s
    JOIN address_class a
    ON (s.event_from = a.address)
    AND date_trunc('day', s.block_timestamp) = a.date

    WHERE date_trunc('day', s.block_timestamp) > getdate() - interval '1 month'
    AND a.address_tag IS NOT NULL
    GROUP BY 1,2
    ORDER BY 1