select * from emp where deptno = 10;
select empno,ename,deptno from emp where job = 'SA_MAIN';
select empno,sal,comm,(sal+nvl(comm,0)) sum from emp;
select * from emp where job='SALESMAN' and deptno=30 or (job = 'MANAGER' and deptno = 20);
SELECT * FROM EMP WHERE SAL>=2000 AND JOB NOT IN('CLECK','MANAGER');
select deptno,ename,comm from emp where comm!=0;
select * from emp where comm is null or (comm <=100);
select ename from emp where ename not like '%S%';
select ename,hiredate from emp order by hiredate;
select a.ename,b.ename magename from emp a join emp b on b.empno=a.mgr;
select a.ename,b.hiredate marname,a.hiredate from emp a join emp b on a.hiredate<b.hiredate and a.mgr = b.empno;
select d.deptnod,d.dname,d.loc,e.ename marname from emp e join dept d where e.deptno=d.deptno;
select d.deptno,e.* from dept d left join empno d.deptno = e.deptno;
select d.deptno,e.* from dept d,emp e where d.deptno=e.deptno(+);
select d.deptno,e.* from dept d left join emp e on d.deptno=e.deptno;
select empno,ename,dname,job,sal,comm from emp e,dept d where e.deptno=d.deptno;
select * from dept d where exists(select * from emp e where e.deptno=d.deptno);
select * from emp where sal>(select sal from emp where empno=7499);
select * from emp where sal>(select avg(sal) from emp);
select max(sal),job from emp group by job;
select distinct job,sal from emp e where sal=(select max(sal) from emp where job=e.job);
select count(*),deptno,avg(sal) from emp group by deptno;
select count(*),job,avg(sal) from emp group by job;
select deptno,job,count(*),avg(sal) from emp group by deptno,job order by deptno;
select distinct job from emp where sal>5000;
select e.*,dname,d.deptno from emp e,dept d where e.deptno=d.deptno and e.deptno in
(select deptno from emp group by deptno having avg(sal)<6000);
select ename from emp where deptno in(select deptno from dept where dname='SALES');
select * from emp where job=(select job from emp where empno= 7499);
select ename,sal from emp where sal>all(select sal from emp where deptno=30);
select count(*),avg(sal),avg(round((sysdate-hiredate)/365)),deptno from emp group by deptno;
select * from emp where sal = any(select avg(sal) from emp group by deptno);
select * from emp where sal in(select avg(sal)from emp group by deptno);
select * from emp e1 where sal>(select avg(sal)from emp e2 where e2.deptno=e1.deptno);
select e.*,a.avgsal from emp e,(select deptno,avg(sal) as avgsal from emp group by deptno) a where a.deptno=e.deptno and e.sal>a.avgsal;
select * from emp e1 where sal> any(select sal from emp e where deptno=20);
select * from emp e where nvl(sal,0)+nvl(comm,0) in (select nvl(sal,0)+nvl(comm,0) from emp e1 where e1.deptno=10 and e.sal=e1.sal and e.comm=e1.comm and e.deptno!=10);
select * from emp where deptno in(select deptno from emp group by deptno having count(empno)>5);
select * from dept where deptno in(select deptno from emp group by deptno having min(sal)>1000);
select * from emp e join dept d on d.deptno in (select deptno from emp where deptno not in (select distinct deptno from emp where sal<1000)) and d.deptno=e.deptno;
select * from dept where deptno in(select deptno from emp group by deptno having min(sal)>900 and max(sal)<3000);
select * from dept where deptno in (select deptno from emp group by deptno having count(*)=all(select max(count(*)) from emp group by deptno));
select * from (select * from emp where deptno=30 order by sal desc) e where rownum<4;
select * from emp where empno in(select empno from(select empno,rownum num from(select empno,sal from emp order by sal desc))where num between 5 and 10);
update emp e set sal=1000+(select avg(sal) from emp where deptno=e.deptno);
select * from emp where hiredate=last_day(hiredate)-2;
select * from emp where round((sysdate-hiredate)/365) > 10;
select upper(substr(ename,1,1)) || lower(substr(ename,2,length(ename)-1)) from emp;
select * from emp where length(ename)= 6;
select * from emp where ename like '_M%';
select replace(ename,'s','S') from emp;
select * from emp where to_char(hiredate,'MM')='02';