Sie sind auf Seite 1von 3

ASSIGNEMENT

To practice these queries make the following database


Empno number P.K
Ename text
Job text
Sal number
Comm number
Deptno number F.K
1. Select * from abc; Done
2. Select * from abc Where ename=‘SMITH’; Done
3. Select ename, job from abc; Done
4. Select ename, job from abc Where =‘MANAGER’; Done
5. Select ename, sal*12 from abc; Done
6. Select ename, sal “Salary” from abc; Done
7. Select * from abc Where job=‘CLERK’ and deptno=20; Done
8. Select * from abc Where deptno=20; Done
9. Select * from abc Where not(job=‘CLERK’ and deptno=20);Done
10. Select * from abc Where deptno=20 and(job=‘CLERK’ or
job=‘MANAGER’);Done
11. Select * from abc Where sal between 1200 and 3000; Done
12. Select * from abc Where sal not between 1200 and 3000; Done
13. Select * from abc Where job in (‘CLERK’, ‘MANAGER’);Done
14. Select * from abc Where deptno in (10,30); Done
15. Select * from abc Where job not in (‘CLERK’, ‘MANAGER’);Done
16. Select * from abc Where deptno not in (10,30);Done
17. Select * from abc Where comm is null; Done
18. Select * from abc Where comm is not null; Done
19. Select * from abc Where comm is null and sal >=3000;
20. Select * from abc Where ename like ‘S%’;
GROUP BY AND HAVING Done
21. Select job, sum(sal) From emp Group by job;
22. Select job, avg(sal) From emp Group by job;
23. Select job, max(sal) From emp Group by job;
24. Select deptno, count(*) From emp Group by deptno;
25. Select job, avg(sal) From emp Where job=‘MANAGER’ Group by job;
26. Select job, max(sal) From emp Having max(sal) >=3000 Group by job;
27. Select job, sum(sal) From emp Where sal > 1500 Group by job;
28. Select deptno, avg(sal) From emp Having avg(sal) > 2000 Group by
deptno;
29. Select deptno, count(*) From emp Having count(*) > 5 Group by
deptno;
30. Select deptno, sum(sal) From emp Where job not in(‘CLERK’,
‘MANAGER’) Having sum(sal) > 2000 Group by deptno;

NESTED QUERIES

31. Select * from emp Where job=(select job from emp where
ename=‘FORD’);
32. Select * from emp Where mgr=(select mgr from emp where
ename=‘WARD’);
33. Select * from emp Where deptno=(select deptno from emp where ename
= ‘MARTIN’);
34. Select ename, sal, job, deptno From emp Where sal > any(select distinct
sal from emp where deptno=30);
35. Select ename, sal, job, deptno From emp Where sal > all(select distinct
sal from emp where deptno=30);

Das könnte Ihnen auch gefallen