标签:order by group by having where条件 聚合函数
SELECT distinct deptno,job,empno FROM EMP order by deptno;
SELECT a.deptno,a.job FROM EMP a; SELECT distinct a.deptno,a.job FROM EMP a order by a.deptno
SELECT a.deptno,a.job FROM EMP a; SELECT distinct a.deptno,a.job FROM EMP a order by a.deptno
select trunc(5555.66666,2.1),trunc(5555.66666,-2.6),trunc(5555.033333) from dual;
SELECT a.ename,(a.sal*13+nvl(a.comm,0)*13) as "年薪", a.ename||'-'||(a.sal*13+nvl(a.comm,0)*13) as "拼接字串"FROM EMP a ;
SELECT * FROM EMP a WHERE to_char(a.hiredate,'yyyy-mm-dd') > '1981-11-17';
SELECT * FROM EMP a WHERE a.sal between 2000 and 2500;--包含本身,都是闭区间SELECT * FROM EMP a WHERE a.sal >= 2000 and a.sal <= 2500;
SELECT * FROM EMP a WHERE a.empno in (7369,7521,7654);
SELECT * FROM EMP a WHERE a.mgr IS NULL;
SELECT * FROM EMP a WHERE (a.sal >500 or a.job='MANAGER') and a.ename like 'J%';
SELECT * FROM EMP a order by a.sal;--一个条件 SELECT * FROM EMP a order by a.deptno , a.hiredate desc;--2个条件
SELECT a.ename,(a.sal*13+nvl(a.comm,0)*13) as "年薪" FROM EMP a order by 年薪;
SELECT a.ename,(a.sal*13+nvl(a.comm,0)*13) as "年薪" FROM EMP a order by 1;
SELECT max(a.sal),min(a.sal) FROM emp a ; SELECT max(a.sal*13) , min(a.sal*13) FROM emp a ;
SELECT round(avg(a.sal),2),sum(a.sal) FROM emp a ;
SELECT avg(a.comm) FROM emp a ; SELECT sum(a.comm)/count(*) FROM emp a ;
SELECT count(*) FROM emp a ;SELECT count(a.empno) FROM emp a ;
SELECT count(a.comm) FROM emp a ;
SELECT a.ename,a.job FROM emp a WHERE a.sal = (SELECT max(a.sal) FROM emp a);
SELECT a.ename,a.job FROM emp a WHERE a.sal > (SELECT avg(a.sal) FROM emp a);
SELECT avg(a.sal), max(a.sal),a.deptno FROM emp a group by a.deptno;
SELECT avg(a.sal), max(a.sal),a.deptno,a.job FROM emp a group by a.deptno ,a.job order by a.deptno ;
SELECT avg(a.sal) as "平均工资", a.deptno FROM emp a group by a.deptno having avg(a.sal)<2000
标签:order by group by having where条件 聚合函数
原文地址:http://blog.csdn.net/u012228718/article/details/46310161