????1???г??????????????????в????
??????????????????ж??????  —— ???????????з???
????select deptno??count(*) from emp group by deptno having count(*) >= 1;
????2???г?н???“SMITH”????????????
????????????????SMITH????  ?? select sal from emp where ename=’SMITH';
????select * from emp where sal > (select sal from emp where ename=’SMITH’);
????3??***** ?г????????????????????????????????
??????????????????????????????й???  t1 ?????????? t2 ??????????????
????select t1.ename ????????? t2.ename ?????? from emp t1??emp t2 where t1.MGR = t2.empno;
????4???г???????????????????????????????
??????????????????????
????select t1.*??t2.hiredate from emp t1??emp t2 where t1.MGR = t2.empno and t1.hiredate < t2.hiredate;
????5???г????????????Щ????????????????г???Щ????????????
??????????????????????? — ??????????????????????????????????????????????
????select * from dept left outer join emp on dept.deptno = emp.deptno ;
????6???г?????“CLERK”??????????????????????????
??????????????job?CLERK ????????????????
??????????? emp??
???????????? dept??
????select emp.ename??dept.dname??emp.job from emp??dept where emp.deptno = dept.deptno and emp.job=’CLERK';
????7???г???н?????1500??????????
?????????????????н?? —- ?????????飬???н??
????select min(sal) from emp group by job;
????????1500 ????????????? — having
????select job??min(sal) from emp group by job having min(sal) > 1500;
????8???г??????“SALES”???????????????????????????????????????????????
?????????????????λ?? emp  ???????? dept
????select emp.ename from emp??dept where emp.deptno = dept.deptno and dept.dname = ‘SALES';
????9???г?н??????????н????????????
??????????????????н?? select avg(sal) from emp;
????select * from emp where sal > (select avg(sal) from emp);
????10???г???“SCOTT”??????????????????????
??????????????SCOTT : select job from emp where ename =’SCOTT';
????select * from emp where ename <> ‘SCOTT’ and job = (select job from emp where ename =’SCOTT’);
????11???г?н????????30???????н??????????????????н??
????????????????30 ?????????н???б? select sal from emp where deptno = 30;
????select * from emp where sal in (select sal from emp where deptno = 30);
????12???г?н??????????30???????????????н????????????н??
??????????
????select * from emp where sal > all(select sal from emp where deptno = 30);
????select * from emp where sal > (select max(sal) from emp where deptno = 30);
????13???г????????????????????????????????
???????????????????
????select deptno?? count(*)??avg(sal)  from emp group by deptno;
????14???г?????????????????????????????
??????????
????select emp.ename??dept.dname??emp.sal from emp??dept where emp.deptno = dept.deptno;
????15???г????в?????????????????????
??????????
????select dept.*??count(emp.*) from emp??dept where emp.deptno = dept.deptno group by deptno ; ????
???????????????????? select deptno??count(*) from emp group by deptno;
???????dept????? select dept.*??temp.???????? from dept ?? (select deptno??count(*) ???????? from emp group by deptno) temp where dept.deptno = temp.deptno ;
????16???г???????????????
?????????????????? ???? ?? ????? min
????select job??min(sal) from emp group by job;
????17???г??????????MANAGER??????????н??
??????????where job=’MANAGER’ ???????в??????????
????select deptno??min(sal) from emp where job =’MANAGER’ group by deptno;
????18???г???????????????????н??????????
?????????? select ename?? sal*12 from emp order by sal*12 asc;
????19.???emp????н???3000?????????3000?????????????????????????н???
?????????? select * from emp where sal >= 3000;
????20.?????????н???’ALLEN’????????????????
??????????select * from emp where sal > (select sal from emp where ename =’ALLEN’);
????21.?????emp???в??????20??н???2000???????????2000??????????????????????????????????н???????????????????????? ??????? н?
?????????? select empno ???????ename ??????? ??sal н? from emp where deptno = 20 and sal > 2000;
????22.?????emp???????е???????????????
?????????? select distinct job from emp;
????23.????????н???comm????β???????????????????
??????????????? is not null
????select * from emp where comm is not null;
????24.?????н???800??2500????????????????????????????????????????and???between and??
??????????select * from emp where sal >= 800 and sal <= 2500;
????select * from emp where sal between 800 and 2500;
????25.???????????7521??7900??7782??????????????????????????????????or???in??
??????????select * from emp where empno in(7521??7900??7782);
????select * from emp where empno=7521 or empno = 7900 or empno = 7782;