Window Function Practice Questions
1. Show each employee’s name, salary, and their rank based on salary (highest salary =
rank 1).
2. Display employee name, deptno, salary, and their dense rank within each department.
3. For every employee, show their salary and the average salary of their department using
AVG() OVER (PARTITION BY deptno).
4. List each employee along with the highest salary in their department using MAX() OVER
(PARTITION BY deptno).
5. Show each employee’s salary and the running total of salaries (cumulative sum) ordered
by salary.
6. Display employees with their salary and the difference between their salary and the
department average using AVG() OVER.
7. For each department, calculate the minimum and maximum salary side by side using
window functions.
8. Show each employee’s salary and the row number based on hiredate (earliest hire = 1).
9. Find the second highest salary in the company using ROW_NUMBER() or RANK().
10. For each department, display employees with their salary and the percent rank
(PERCENT_RANK()) of that salary within the department.