一. 常见单行函数 ( 对每行记录进行操作 )
1) lower(str) //lower() 转换为小写
2) upper(str) //upper() 转换为大写
3) // 从 str 取从 begin 位置开始,数目为 num 的子字符串
//begin 从 1 开始
substr(str, begin, num)
4) chr(65) à A // 将一个数字转换为 ascii 相对应的值
5) ascii(‘A’) à 65 // 将字符转为 ascii 码
6) round(23.65) à 24 // 四舍五入
round(23.65, 1) à 23.7
7) // 将数字类型 salary 转化为特定格式输出
select to_char(salary, ‘$999,999.999’) from emp;
// 将 date 按特定的格式输出
Select to_char(date, ‘YYYY-MM-DD HH:MI:SS’) from emp;
8) // 将字符串转化为 date 格式
select * from emp
where indate >
to_date(‘1985-11-22 10:10:11’, ‘YYYY-MM-DD HH:MI:SS’);
9) // 将字符串转为 number
To_number(‘$1,250,00’, ‘$9,999,99’);
10) // 如果 col 为 null 则返回 instead ,负责返回 col 的值
Nvl(col, insteadof);
二. 多行函数(组函数)
1) max(col)
2) min(col)
3) avg(col)
4) sum(col)
5) count(*) // 所有记录条数,包括 null 值
count(col) // 所有记录条数,不包括 col 为 null 值的记录
count(distinct col) // 所有不重复 col 的记录条数