Assignment 7.
Assignment 7.
Assignment – 7
Write the SQL queries for the following with respect to database created: –
Employee
Bonus
Job_Title
a) Fetch first name of worker using alias name as E_Name.
f) Display all worker details, use order by in first name asec and department in desc.
SELECT First_Name, Last_Name FROM employee WHERE Salary >= 500000 AND Salary <
1000000;
l) Fetch the duplicate records having matching data in some fields of a table.
SELECT * FROM employee WHERE Salary IN (SELECT Salary FROM employee GROUP BY
Salary HAVING COUNT(*) > 1) ORDER BY Department DESC;
q) Display the second highest salary from a table.
SELECT DISTINCT Salary FROM employee emp1 WHERE 3 >= (SELECT COUNT(DISTINCT
Salary) FROM employee emp2 WHERE emp2.Salary <= emp1.Salary) ORDER BY emp1.Salary
DESC;
u) Fetch departments along with the total salaries paid for each of them.