1.
Write a query in SQL to display the full name (first and last name), and salary
for those employees who earn below 6000.?
SELECT first_name ||' '||last_name AS Full_Name, salary FROM employees WHERE salary
< 6000;
2. Write a query in SQL to display the first and last_name, department number and
salary for those employees who earn more than 8000
SELECT first_name,last_name,department_id,salary from employees where salary >
8000;
3. Write a query in SQL to display the first and last name, and department number
for all employees whose last name is �McEwen�
SELECT first_name,last_name,department_id from employees where last_name ='McEwen';
4. Write a query in SQL to display all the information for all employees without
any department number.
SELECT * from employees where department_id is null;
5. Write a query in SQL to display the full name (first and last), hire date,
salary, and department number for those employees whose first name does not
containing the letter M
and make the result set in ascending order by department number?
select first_name,last_name,department_id,hire_date,salary from employees where
first_name not like '%M%' order by department_id;
7. Write a query in SQL to display all the information of employees whose salary is
in the range of 8000 and 12000 and commission is not null
or department number is except the number 40, 120 and 70 and they have been hired
before June 5th, 1987.
select * from employees where salary between 8000 and 12000 and COMMISSION_PCT is
not null or department_id not in(40, 120, 70) and hire_date< '1987-06-05';
8. Write a query in SQL to display the full name (first and last), the phone number
and email separated by hyphen, and salary, for those employees
whose salary is within the range of 9000 and 17000. The column headings assign with
Full_Name, Contact_Details and Remuneration respectively.
select first_name ||' '||last_name AS Full_Name,PHONE_NUMBER||'-'||EMAIL as
CONTACT_DETAILS ,SALARY AS REMUNERATION FROM EMPLOYEES WHERE SALARY BETWEEN 9000
and 17000;
9 . Write a query in SQL to display the first and last name, and salary for those
employees whose first name is ending with the letter m
select first_name,last_name,salary from employees where first_name LIKE '%M';
10.. Write a query in SQL to display the full name (first and last name), salary,
and manager number for those employees who is working under a manager.
SELECT first_name ||' '||last_name AS Full_Name, salary, manager_id FROM employees
WHERE manager_id IS NOT NULL;
JOINS
1. Write a query in SQL to display the first name, last name, department number,
and department name for each employee
SELECT E.first_name,E.last_name,D.department_id FROM EMPLOYEES E JOIN DEPARTMENTS D
ON E.DEPARTMENT_ID=D.DEPARTMENT_ID;
2.Write a query in SQL to display the first and last name, department, city, and
state province for each employee.
SELECT E.first_name,E.last_name,D.department_NAME,L.CITY,L.STATE_PROVINCE FROM
EMPLOYEES E JOIN DEPARTMENTS D ON E.DEPARTMENT_ID=D.DEPARTMENT_ID JOIN LOCATIONS L
ON D.LOCATION_ID=D.LOCATION_ID;
3. Write a query in SQL to display the first name, last name, salary, and job grade
for all employees.
SELECT E.first_name,E.last_name,E.SALARY,J.GRADE_LEVEL FROM EMPLOYEES E JOIN
job_grades J ON E.SALARY BETWEEN J.LOWEST_SAL AND J.HIGHEST_SAL;
5. Write a query in SQL to display those employees who contain a letter z to their
first name and also display their last name, department, city, and state province.
select e.first_name,e.last_name,d.department_name,l.city,l.state_province from
employees e join departments d on d.department_id=e.department_id join locations l
on l.location_id =d.location_id where e.first_name like '%z%'
6. Write a query in SQL to display all departments including those where does not
have any employee
SELECT E.first_name, E.last_name, D.department_id, D.department_name
FROM employees E
RIGHT OUTER JOIN departments D
ON E.department_id = D.department_id;
7. Write a query in SQL to display the first and last name and salary for those
employees who earn less than the employee earn whose number is 182
SELECT E.first_name, E.last_name, E.salary
FROM employees E
JOIN employees S
ON E.salary < S.salary
AND S.employee_id = 182;
8. Write a query in SQL to display the first name of all employees including the
first name of their manager.
SELECT E.first_name AS "Employee Name",
M.first_name AS "Manager"
FROM employees E
JOIN employees M
ON E.manager_id = M.employee_id;
9. Write a query in SQL to display the department name, city, and state province
for each department.
SELECT D.department_name , L.city , L.state_province
FROM departments D
JOIN locations L
ON D.location_id = L.location_id;
10. Write a query in SQL to display the first name, last name, department number
and name, for all employees who have or have not any department.
SELECT E.first_name, E.last_name, E.department_id, D.department_name
FROM employees E
LEFT OUTER JOIN departments D
ON E.department_id = D.department_id;
11. Write a query in SQL to display the first name of all employees and the first
name of their manager including those who does not working under any manager.
SELECT E.first_name AS "Employee Name",
M.first_name AS "Manager"
FROM employees E
LEFT OUTER JOIN employees M
ON E.manager_id = M.employee_id;
12. Write a query in SQL to display the first name, last name, and department
number for those employees who works in the same department as the employee who
holds the last name as Taylor.
SELECT E.first_name , E.last_name , E.department_id
FROM employees E
JOIN employees S
ON E.department_id = S.department_id
AND S.last_name = 'Taylor';