Subquery for percentage-of-total calculation
For the investor update — 2025 revenue by account with share of total. Columns: `account_name`, `revenue`, `pct_of_total`. Only revenue accounts, posted entries, sorted by revenue DESC.
Each hint you reveal reduces the XP you can earn. Try the query first.
JOIN fact_transactions and dim_accounts, filter LOWER(account_type) = 'revenue' and posted = 1 and 2025.
GROUP BY account_name, SUM(amount) AS revenue.
pct_of_total = revenue / (SELECT SUM(amount) FROM ... WHERE same filters) — a scalar subquery.