SQL Case Study 2
SQL Case Study 2
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:
7. List out the employees whose name starts with 'S' and ends with 'H'.
8. List out the employees whose name length is 4 and start with 'S'.
9. List out employees who are working in department 10 and draw salaries more
than 3500.
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.
Joins:
1. List out employees with their department names.
2. Display employees with their designations.
3. Display the employees with their department names and regional groups.
4. How many employees are working in different departments? Display with
department names.
5. How many employees are working in the sales department?
6. Which is the department having greater than or equal to 5
employees? Display the department names in ascending
order.
7. How many jobs are there in the organization? Display with designations.
8. How many employees are working in "New York"?
9. Display the employee details with salary grades. Use conditional statement to
create a grade column.
10. List out the number of employees grade wise. Use conditional statement to
create a grade column.
11. Display the employee salary grades and the number of employees
between 2000 to 5000 range of salary.
12. Display all employees in sales or operation departments.
SET Operators:
1. List out the distinct jobs in sales and accounting departments.
2. List out all the jobs in sales and accounting departments.
3. List out the common jobs in research and accounting
departments in ascending order.
Subqueries:
1. Display the employees list who got the maximum salary.