What is a window function?
Solution
It calculates across related rows without collapsing them.
SELECT name,salary,AVG(salary) OVER() company_avg FROM employees;
Think before looking at the solution
- What would the SQL query do?
- Which rows will match?
- Which columns will appear?
- What happens when NULL values are involved?
- Can the query be improved using an index?
