Introduction to Analytical Functions
These functions compute values across rows while retaining detail records. They're useful in reporting, ranking, and trend analysis.
Used with OVER() clause and optional PARTITION BY, ORDER BY.
SELECT employee_id, department_id, salary,
AVG(salary) OVER (PARTITION BY department_id) AS dept_avg
FROM employees;