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

Second Highest Salary of Employee

This SQL document contains 3 queries: 1) Finds the second highest salary from the employee table, 2) Finds the maximum salary for each department by grouping on department ID, 3) Deletes any duplicate rows in the employee table based on the employee number, keeping only the record with the maximum row ID.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views1 page

Second Highest Salary of Employee

This SQL document contains 3 queries: 1) Finds the second highest salary from the employee table, 2) Finds the maximum salary for each department by grouping on department ID, 3) Deletes any duplicate rows in the employee table based on the employee number, keeping only the record with the maximum row ID.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

second highest salary of Employee

select Max (salary) from employee where salary not in (select


max(salary) from employee);

2. Max sal from each department

SELECT DeptID, MAX(Salary) FROM Employee GROUP BY DeptID;

3. Delete duplicate rows in a database

DELETE FROM emp a WHERE rowid != (SELECT MAX(rowid) FROM emp


b WHERE a.empno=b.empno);

You might also like