Window Functions

In Oracle, window functions offer a powerful way to perform aggregate calculations without collapsing rows into a single result. Unlike traditional aggregate functions that group data, window functions maintain the original dataset while providing aggregated values based on specified partitions. The syntax is: SELECT column_name, aggregate_function() OVER (PARTITION BY column_name) FROM table_name;. For example:

sqlCopy codeSELECT employee_id, salary, AVG(salary) OVER (PARTITION BY department_id) AS avg_dept_salary FROM employees;

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *