一、字符函数sql
upper(字符/查询的字段名):单词全大写;sql语句->select upper('name') from dual;函数
initcap(字符/查询的字段名):单词首字母大写code
lower(字符/查询的字段名):单词小写字符串
concat(字符/查询的字段名):链接字符串,可是链接字符串可用“||”it
substr(字符/查询的字段名):字符串截取;substr('hello',1,3)->hel(彷佛从0开始截取也是同样的)io
length(字符/查询的字段名):字符串长度->length('hello')=5ast
replace(字符/查询的字段名):内容替换;replace('hello','l','x')->hexxodate
trim(字符/查询的字段名):去空格select
二、数值函数sql语句
round():四舍五入->round(789.436,2)=789.44
round(789.436,-2)=800
trun():截取小数点,不保留小数点,也不四舍五入->
trun(789.536)=789
trun(789.536,2)=789.53
mod():取余数->mod(10,3)=1
floor():向下取整
三、日期函数
当前日期:select sysdate from dual
months_between():求给定日期范围的月数
add_months():在指定日期上加上指定的月数,求出以后的日期
next_months():下一个今天是哪个日期
last_day():求出给定日期最后一天的日期
四、转行函数
to_char():转换成字符串->to_char(列名,'yyyy')year; to_char(列名,'mm')months
to_number():转换成数字
to_date():转换成日期
....fm消除前导零
五、通用函数
nvl():将指定空值变为指定内容->nvl(comm,'0')变为’0‘
decode():相似于if...elseif...else
decode(col/expession,search1,result1,search2,result2,search3,result3) from 表
col/expession=search1 结果是result1
col/expession=search2 结果是result2
col/expession=search3 结果是result3