![60de8541bd419c9ad820a11ef998b1e8.png](https://img-blog.csdnimg.cn/img_convert/60de8541bd419c9ad820a11ef998b1e8.png)
1.round
例子:
select round(23.4),round(23.45,1),
round(23.45,-1) from employees;
结果:23 23.5 20
2.trunc 取整精度函数
select trunc(12.35) from dual
结果:12
3.ceil/floor 取整函数
例子:
select ceil(23.45),floor(23.45) from emp;
结果:24 23
4.计算函数
(1) abs 取绝对值
例子:
select abs(23.45),abs(-23),abs(0) from emp;
结果:23.45 23 0
(2) mod(m,n) 取余数
select mod(5,2) from emp 结果: 1
select mod(5,null) from emp 结果就是空
(3) power(m,n) 返回m的N次幂
select power(2,3) from emp;
(4) sqrt:求平方根
select sqrt(16) from emp 结果 4
5.聚合函数
(1)sum 求和函数
select sum(a.salary) from stuinfo a;
(2)count 统计函数
select count(*) from stuinfo a;
(3)avg 平均函数
select avg(a.salary) from stuinfo a;
(4)max 最大值函数
select max(a.salary) from stuinfo a;
(5)min 最小值函数
select min(a.salary) from stuinfo a;
6.字符函数
(1) upper 小写转大写
(2) lower 大写转小写
(3) initcap首字母大写
(4) substr (char,[m[,n]])获取子字符串函数
注:负号是从结尾往回数
select substr('abcde',2,3),substr('abced',2),
substr('abced',-2,1) from emp;
结果: bcd bcde e
(5) length获取字符串长度
select length('abc') from emp;
结果:3
<