Kanja
Kanja
SCREENSHOTS ANSWERS.
1. From the employees table, write a SQL query to find those employees
whose salary is less than 6000. Return full name (first and last name),
and salary
2. From the employees table, write a SQL query to find those employees
whose salary is higher than 8000. Return first name, last name and
department number and salary.
3. From the employees table, write a SQL query to find those
employees
whose last name is "McEwen". Return first name, last name and
department
ID
6. From the employees table, write a SQL query to find those employees
who falls in the employees criteria : 1. whose salary is in the range
of
8000, 12000 (Begin and end values are included.) and get
some
commission. 2. : those employees who joined before ‘2003-06-05’
and
not included in the department number 40, 120 and 70. Return all fields.
Sample Solution:
Sample Solution:
9. From the employees table, write a SQL query to find those employees
whose salary is not in the range 7000 and 15000 (Begin and end
values
are included). Sort the result-set in ascending order by the full name
(first and last). Return full name and salary.
10. From the employees table, write a SQL query to find those
employees
who were hired during November 5th, 2007 and July 5th, 2009.
Return
full name (first and last), job id and hire date.
Sample Solution:
11. From the employees table, write a SQL query to find those
employees who works either in department 70 or 90. Return full name
(first and last name), department id.
12. From the employees table, write a SQL query to find those
employees
who work under a manager. Return full name (first and last
name),
salary, and manager
ID
13. From the employees table, write a SQL query to find those
employees
who were hired before June 21st, 2002. Return all fields.
14. From the employees table, write a SQL query to find those
employees
whose managers hold the ID 120 or 103 or 145. Return first name,
last
name, email, salary and manager
ID
15. From the employees table, write a SQL query to find those
employees
whose first name contains the letters D, S, or N. Sort the result-set
in
descending order by salary. Return all fields.
16. From the employees table, write a SQL query to find those
employees
who earn above 11000 or the seventh character in their phone
number
is 3. Sort the result-set in descending order by first name. Return full
name (first name and last name), hire date, commission percentage,
email, and telephone separated by '-', and
salary
17. From the employees table, write a SQL query to find those employees
whose first name contains a character ‘s’ in 3rd position. Return
first
name, last name and department id.
18. From the employees table, write a SQL query to find those
employees
who are working in the departments, which are not included in
the
department number 50 or 30 or 80. Return employee_id, first_name,
job_id, department_id.
20. From the employees table, write a SQL query to count the
number of
employees, sum of all salary, and difference between the highest
salary
and lowest salary by each job id. Return job_id, count,
sum,
salary_differenc
e
21. From the employees table, write a SQL query to count the number of
employees worked under each manager. Return manager ID and
number of employees.
22. From the employees table, write a SQL query to find all those
employees who are either Sales Representative or Salesman. Return
first name, last name and hire date.
23. From the employees table, write a SQL query to calculate average
salary of those employees for each department who get a
commission
percentage. Return department id, average salary.
26. From the employees table, write a SQL query to find those
employees
whose first name or last name starts with the letter ‘D’. Return first
name, last
name.
27. From the employees table, write a SQL query to find those
employees
who joined after 7th September 1987. Return all the fields