数据库---oracle学习笔记2

select ename from emp where sal=(select max(sal) from emp);
select ename from emp where sal>(select avg(sal) from emp);
select max(sal) from deptno from emp group by deptno;
select ename ,sal from emp join
(select max(sal) max_sal,deptno from emp group by deptno ) t
on (emp.sal = t.max_sal and emp.dempno = t.deptno);
select avg(sal) group by deptno; --avg_sal
select emp.ename, a.ename from emp join (select ename from emp ) a
on emp.mgr = a.empno;
select e1.ename ,e2.ename from emp e1,emp e2 where e1.mgr = e2.empno; ---子链接起不同的别名

你可能感兴趣的:(oracle)