SQL Case Study 2 1
SQL Case Study 2 1
LOCATION
Location_ID(PK) City
122 New York
123 Dallas
124 Chicago
167 Boston
DEPARTMENT
JOB
Job_ID(PK) Designation
667 Clerk
668 Staff
669 Analyst
671 Manager
672 President
EMPLOYEE
Employe Last_Na First_Na Middle_ Job_Id( Hire Date Salary Comm Depart
e_Id me me Name FK) ment_Id
(FK)
7369 Smith John Q 667 17-Dec-84 800 Null 20
7499 Allen Kevin J 670 20-Feb-85 1600 300 30
755 Doyle Jean K 671 04-Apr-85 2850 Null 30
756 Dennis Lynn S 671 15-May-85 2750 Null 30
757 Baker Leslie D 671 10-Jun-85 2200 Null 40
7521 Wark Cynthia D 670 22-Feb-85 1250 50 30
Simple Queries:
WHERE Condition:
9. List out the employees who are working in department 30 and draw the
salaries more than 2500.
10. List out the employees who are not receiving commission.
ORDER BY Clause:
1. List out the Employee ID and Last Name in ascending order based on the
Employee ID.
2. List out the Employee ID and Name in descending order based on salary.
3. List out the employee details according to their Last Name in ascending-order.
4. List out the employee details according to their Last Name in ascending
order and then Department ID in descending order.
CONDITIONAL STATEMENT
1. Display the employee details with salary grades. Use conditional statement to
create a grade column.
2. List out the number of employees grade wise. Use conditional statement to
create a grade column.
3. Display the employee salary grades and the number of employees between
2000 to 5000 range of salary.
Subqueries:
1. Display the employees list who got the maximum salary.
2. Display the employees who are working in the sales department.
3. Display the employees who are working as 'Clerk'.
4. Display the list of employees who are living in 'Boston'.
5. Find out the number of employees working in the sales department.
6. Update the salaries of employees who are working as clerks on the basis of
10%.
7. Display the second highest salary drawing employee details.
8. List out the employees who earn more than every employee in department 30.
9. Find out which department has no employees.
10. Find out the employees who earn greater than the average salary for
their department.