select comm from emp;
--查询工资最高的员工
select ename,job,sal from emp where sal = (select max(sal) from emp);
select ename,job,sal*13+nvl(comm,0)*13 s from emp order by s desc;
--查询平均工资,总工资
select avg(nvl(sal,0)),sum(nvl(sal,0)) from emp;
--查询奖金
select avg(comm),sum(comm) from emp;
--group by 和having
select avg(sal),sum(sal),deptno from emp group by deptno;
select count(comm) from emp ;
select count(ename) from emp ;
----显示每个部门的每种岗位的平均工资和最高工资
select avg(sal),sum(sal),deptno,job from emp group by deptno, job
----显示部门平均工资低于2000的部门和他的平均工资
--思路1:查询出每个部门的平均工资
select avg(sal),deptno from emp GROUP by deptno;
--思路2:挑出低于2000的部门
select avg(sal),deptno from emp GROUP by deptno HAVING AVG(sal)
当前位置: 数据库>oracle
Oracle复杂查询入门教程
来源: 互联网 发布时间:2017-05-15
本文导语: select comm from emp;--查询工资最高的员工select ename,job,sal from emp where sal = (select max(sal) from emp);select ename,job,sal*13+nvl(comm,0)*13 s from emp order by s desc;--查询平均工资,总工资 select avg(nvl(sal,0)),sum(nvl(sal,0)) from emp;--查询奖金select avg(comm),sum...