PostgreSQL - Window Functions in PostgreSQL
You want to calculate a running average salary per department ordered by hire date. Which query correctly uses AVG() as a window function?
SELECT employee_id, department, salary, AVG(salary) OVER (PARTITION BY department ORDER BY hire_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS running_avg FROM employees; correctly uses all required clauses in correct order and frame specification.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions