DBMS_Lab_5
DBMS_Lab_5
1. Write a query in SQL to display the first name, last name, department number, and department name
for each employee. (Sample tables: employees & departments)
select e1.employee_id,e1.last_name,e1.manager_id,e2.last_name
from employees e1, employees e2
where e2.employee_id = e1.manager_id;
5. Write a query to find the name (first_name, last_name) and hire date of the employees who was hired
after 'Jones'. (Sample tables: employees)
select d.department_id,d.department_name,e.first_name
from departments d
inner join employees e
where d.manager_id = e.employee_id;
8. Write a query to display the department name, manager name, and city. (Sample tables: employees ,
locations & departments)
select d.department_name,e.first_name,l.city
from departments d
inner join employees e
inner join locations l
where d.manager_id = e.employee_id and d.location_id = l.location_id;
9. Write a query to display the job history that were done by any employee who is currently drawing
more than 10000 of salary. (Sample tables: employees & job_history)
select j.*
from job_history j
inner join employees e using (employee_id)
where e.salary>10000;
10. Write a query to display the first name, last name, hire date, salary of the manager for all managers
whose experience is more than 15 years. (Sample tables: employees & departments)
select first_name,last_name,hire_date,salary
from departments d
inner join employees e ON (d.manager_id = e.employee_id)
where (datediff(now(),e.hire_date))/365 > 15;
11. Write a query in SQL to display the name of the department, average salary and number of employees
working in that department who got commission. (Sample tables: employees & departments)
select j.*
from job_history j
inner join employees e on j.employee_id = e.employee_id
where e.salary >= 12000;
15. Write a query in SQL to display the full name (first and last name), and salary of those employees who
working in any department located in London. (Sample tables: employees , locations & departments)
The End