一个SQL

来源:互联网 发布:齐鲁大学生软件大赛 编辑:程序博客网 时间:2024/05/21 09:36

多行子查询,多列:

select * from emp where (deptno,job)=(select deptno,job from emp where ename='SMITH');

查询自己部门工资高于平均部门平均工资的人的信息;

select a2.ename,a2.sal,a2.deptno from emp a2,(select deptno,avg(sal) mysal from emp group by deptno) a1 where a2.deptno=a1.deptno and a2.sal>a1.mysal;select * from emp a2,(select deptno,avg(sal) mysal from emp group by deptno) a1 where a2.deptno=a1.deptno and a2.sal>a1.mysal;


原创粉丝点击