Explore Library
Quiz

Nesting Aggregates Inside Window Functions

Understand why SUM(SUM(x)) OVER () is valid and what it computes over grouped rows.

Consider: SELECT department, SUM(salary) AS dept_total, SUM(salary) / SUM(SUM(salary)) OVER () * 100 AS pct_of_company FROM employees GROUP BY department; What does the expression SUM(SUM(salary)) OVER () evaluate to for each row?