DBMS LAB EXPERIMENT WEEK6
DBMS LAB EXPERIMENT WEEK6
2. Display the employee number and name for employee working as clerk and earning highest
salary among clerks.
select empno, ename from emp where job='CLERK' and sal=(select max(sal) from emp where
job='CLERK');
Result:
3. Display the names of salesman who earns salary more than the highest salary of any clerk.
select ename, sal from emp where job='SALESMAN' and sal>(select max(sal) from emp
where job='CLERK');
Result:
Regd. No:
Database Management Systems Lab
2 Aditya College of Engineering & Technology
4. Display the names of clerks who earn a salary more than the lowest salary of any salesman.
select ename from emp where job='CLERK' and sal>(select min(sal) from emp where
job='SALESMAN');
Result:
5. Display the names of the employees who earn highest salary in their respective
departments.
select ename, sal, deptno from emp where sal in(select max(sal) from emp group by
deptno);
Result:
6. Display the names of the employees who earn highest salaries in their respective job groups.
select ename, sal, job from emp where sal in(select max(sal) from emp group by job);
Result:
Regd. No:
Database Management Systems Lab
3 Aditya College of Engineering & Technology
9. Display the Job groups having total salary greater than the maximum salary for managers.
SELECT JOB,SUM(SAL) FROM EMP GROUP BY JOB HAVING SUM(SAL)>(SELECTMAX(SAL)
FROM EMP WHERE JOB='MANAGER');
Result:
10. Display the names of employees from department number 10 with salary greater than that
of any employee working in other department.
select ename from emp where deptno=10 and sal>any(select sal from emp where deptno
not in 10)
Result:
11. Display the names of the employees from department number 10 with salary greater than
that of all employee working in other departments.
select ename from emp where deptno=10 and sal>all(select sal from emp where deptno not
in 10);
Result:
Regd. No:
Database Management Systems Lab
4 Aditya College of Engineering & Technology
Result:
2. delete from emp where empno=7369;
Result: 1 row deleted.
3. select * from emp;
Result:
4. rollback;
Result: rollback completed.
5. select * from emp;
Result:
6. delete from emp where empno<=7550;
Result: 3 rows deleted.
Regd. No:
Database Management Systems Lab
5 Aditya College of Engineering & Technology
7. commit;
Result: commit completed.
8. rollback;
Result: rollback completed.
9. select * from emp;
Result:
10. insert into emp values(7369,'smith','clear',7902,'17-DEC-1980',800,null,20);
Result: 1 row inserted.
11. insert into emp values(7499,'allen','salesman',7698,'20-FEB-1981',1600,300,30);
Result: 1 row inserted.
12. insert into emp values(7521,'ward','salesman',7698,'22-FEB-1981',1250,500,30);
Result: 1 row inserted.
13. savepoint firstrow;
Result: savepoint created.
14. delete from emp where empno=7369;
Result: 1 row deleted.
15. savepoint secondrow;
Result: savepoint created.
16. delete from emp where empno=7499;
Result: 1 row deleted.
17. savepoint thirdrow;
Result: savepoint created.
18. delete from emp where empno=7521;
Result: 1 row deleted.
19. select * from emp;
Regd. No:
Database Management Systems Lab
6 Aditya College of Engineering & Technology
Result:
20. rollback to secondrow;
Result: rollback completed.
21. Select * from emp;
Result:
Regd. No:
Database Management Systems Lab