字符串函数
concat(s1,s2,sn) 拼接字符串
lower(str) 字符串修改为小写
upper(str) 字符串修改为大写
lpad(str,n,pad) 左填充 str填充pad直到长度到达n
rpad(str,n,pad) 右填充
trim(str) 去除头,尾空格
substring(str,2,8) 截取字符串第2位开始截取8个
数值函数
ceil(X) 向上取整
floor(X) 向下取整
mod(x,y) 返回x/y的模
rand() 返回0-1随机数
round(x,y) 返回x的四舍五入保留y位小数
日期函数
curdate() 返回当前日期
curtime() 返回当前日期
new() 返回当前时间和日期
year(date) 返回年
month(date) 返回月
day(date) 返回日
date_add(date,interval expr TYPE) 返回一个日期值加上expr时间间隔 type单位day,month
datediff(date1,date2) 返回两个日期相差天数
流程函数
if(value,t,f)
ifnull(value1,value2) 判断value1是否null,不为null返回value1,为null返回value2
mysql 条件判断
IF(条件,执行1,执行2)
orcle 条件判断
DECODE(字段,字段比较值,执行1,执行2)
case 字段 when ‘值’ then ‘返回值1’ else ‘返回值2’ end
select STAKE_NAME,case STAKE_NAME when '3号桩' then '命中' when '5号桩' then '命中' else '未命中' end from photo_asset_stake;
case when 条件1 then ‘返回值1’ 条件2 then ‘返回值2’ else ‘返回值3’ end
case when math>85 then ‘优秀’ math>60 then ‘及格’ else ‘不及格’ end