sql函数

字符串函数

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值