How can we calculate what percentage of the total workforce belongs to each department?
Dividing group counts by the global window sum (SUM(COUNT(*)) OVER ()) computes percentage shares per group.
Workforce allocation share, departmental percentage distribution, portfolio weightings.
SELECT
department_id,
COUNT(*) AS employee_count,
100.0 * COUNT(*) / SUM(COUNT(*)) OVER () AS percentage_of_employees
FROM employees
GROUP BY department_id;Practice typing production-grade SQL code for Percentage by Group.