oracle学习笔记substr,nvt,max,min,avg,sum,count,group,having
oracle学习笔记substr,nvt,max,min,avg,sum,count,group,having
1 子串 substr select substr(ename,2,3) from emp; 从第二个字符开始截取ename 共截取3个字符; 2 处理空值函数nvl select ename ,sal*12+nvl(comn,0) from emp; 如果是空值(comn),以0代替 3 最大值 select max(sal) from emp 4最小值 select min(sal) from emp; 5 平均值 select avg(sal) from emp; 6 总和 select sum(sal) from emp; 7查询表中有多少条记录 count select count(*) from emp; select count(ename) from emp; 有多少个非空的ename 8分组 group select deptno,avg(sal) from emp group by deptno ; 按照deptno分组给出deptno 和 平均sal 9 对分组的限制 ( 此时不能用where) having select avg(sal),deptno from emp group by deptno having avg(sal) >2000