0% found this document useful (0 votes)
163 views4 pages

Lab Assignment SQL Queries

The document contains a list of 34 SQL queries submitted as part of a lab assignment on the employee table. The queries retrieve and manipulate data from tables like EMP, DEPT, and BONUS. They select, update, delete, and join data to list employee details, filter on job roles and departments, and modify salaries and department assignments.

Uploaded by

sandeep b t
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
163 views4 pages

Lab Assignment SQL Queries

The document contains a list of 34 SQL queries submitted as part of a lab assignment on the employee table. The queries retrieve and manipulate data from tables like EMP, DEPT, and BONUS. They select, update, delete, and join data to list employee details, filter on job roles and departments, and modify salaries and department assignments.

Uploaded by

sandeep b t
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4

Lab Assignments – Employee Table

Submitted to: Prof. Malathi Sriram


Submitted by: Sandeep B T

1. List all employee names, numbers and departments.


select empno, empname, deptno from emp
2. List the names and departments of all the employees who are managers.
select empname,deptno from emp
where job='projmgr'
3. List information about all the employees who work for MANOHAR
select * from emp where deptno in
(select deptno from emp
where empname='manohar arya')
4. List the columns DNAME and DEPTNO from the table DEPT
select deptname, deptno from dept
5. List all the jobs in the table EMP
select job from emp
6. List all the unique jobs in the table EMP
select distinct job from emp
7. List information about employees in Department 130.
select * from emp
where deptno=130
8. List the names, numbers and departments of all TEST.
select empname, empno, deptno from emp
where job='test'
9. Find all department names with department numbers greater than 120.
select deptno, deptname from dept
where deptno>120
10. Find all employees whose commission exceeds their salary.
select * from emp
where comm>salary
11. Find all employees in department 130 whose salary is greater than or equal to 25000.
select * from emp
where deptno=130 and salary>=25000
12. Find all employees who are either managers or have a salary greater than 30000.
select * from emp
where job='projmgr' or salary> 30000
13. List information about employees in department 110 who are not managers or test.
select * from emp
where deptno=110 and job!= 'projmgr’ and job!= 'test'
14. Find employees who are earning between 22000 and 30000 inclusive of both.
select * from emp
where salary between 22000 and 30000
15. List names and department numbers of employees who are test, architects or
developers.
select empname, deptno from emp
where job='test' or job='architect' or job='developers'
16. List jobs and departments of employees whose names begin with M or S.
select job, deptno from emp
where empname like'm%' or empname like's%'
17. List jobs and departments of employees whose names begin with SH and ending
with N.
select job, deptno from emp
where empname like 'sh%n'
18. List grades for the salary falling in the range 30010 to 99999 and 70000 to 90000.
select grade from emp
where losal>=30000 and hisal<=99999
19. List employees and jobs in department 110 and 120 in order of their salary.
select empname, job from emp
where deptno in (110,120)
order by salary
20. Set the salaries of all developers equal to 1:1 time the average salary of developers.
Update emp
Set salary=(select avg(salary) from emp where job=’developer’)
Where job=’developer’
21. Assign Naveen Paul to TESTING-IMPL staff and give him 10% raise in salary.
Update emp
Set deptno=130, salary=1.1*salary
Where ename=’naveen paul’
22. Give 15% raise to all architects in department 120.
update emp
set salary=1.15*salary
where deptno=120 and job='architect'
23. Delete the record of INDRANI S from the BONUS table.
delete from Bonus
where ename='indrani s'
24. Delete all employees with the same job as Bhaskar Rao from the BONUS table.
delete from Bonus
where job in
(select job from bonus
where ename='bhaskar rao')
27. Assign the projects to the employees as below:

alter table emp


add projno numeric(8)
28. Join EMP and DEPT and list departments 130 and 140 with or without employees.
select d.deptname from emp e
join dept deptname d on e.deptno=d.deptno
where d.deptno=130 or d.deptno=140
32. List employees in dept.110 with the same job as anyone in the TESTING dept.
select ename from emp where deptno=110 and
job=(select job from emp where deptno=(select deptno from dept where
deptname=’TESTING-IMPL’))
33. Find all the average salary of employees in their own departments, and list them, in
department order.
select e.ename, avg_sal from emp e
join dept d on e.deptno=d.deptno,
avg_sal=(select avg(salary) from emp group by deptno)
34. Display information about employees who have at least one other employee
reporting to them
Select * from emp where mgr is NULL

You might also like