运算符与数据库函数

1.length函数

select length('理由');

2.floor /ceiling/truncate 函数

floor 返回比数值小的整数

celing 返回比数值大的整数

select floor(2.5);
select ceiling(2.5);

round四舍五入函数实例

select round(114.566);

select round(114.566,2);

select round(114.566,-1);

3.date_add 函数

 select date_add('1997-12-24 12:00:00',interval 2 month) as newtime;

select date_add('1997-12-24 12:00:00',interval -10 hour) as newtime;

select date_add('1997-12-24 12:00:00',interval '10:50' MINUTE_SECOND) as newtime;

4.extract函数   从日期时刻中取值

select extract(year_Month from '1997-12-24 12:00:00');

5.case 函数

SELECT name,
CASE sex
WHEN 0 then 'Bargain'
WHEN 1 then 'hello'
ELSE 'Gift to impress relatives'
END as sex
FROM customer ;

猜你喜欢

转载自www.cnblogs.com/helloworld2019/p/10716984.html
今日推荐