Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views1 page

Window Function Practice Questions

The document contains a series of practice questions focused on SQL window functions. It includes tasks such as ranking employees by salary, calculating average and maximum salaries within departments, and determining running totals and salary differences. Each question aims to enhance understanding and application of window functions in SQL queries.

Uploaded by

ganesh.jaddu97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Window Function Practice Questions

The document contains a series of practice questions focused on SQL window functions. It includes tasks such as ranking employees by salary, calculating average and maximum salaries within departments, and determining running totals and salary differences. Each question aims to enhance understanding and application of window functions in SQL queries.

Uploaded by

ganesh.jaddu97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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.

You might also like