07 sql函数

函数:
切记函数和括号要紧密相连
内置函数
1.算术函数abs mod round
max min avg sum count 这几个为聚集函数,特别在分组中常用

select abs(-1);
select mod(101,2);
select round(37.25,1);

2.字符串函数 concat,length,char_length,lower,upper,replace,substring

select concat("111","222","333");
select length("7777年后咕咕咕");
select char_length("7777年后咕咕咕");
select lower("777ABC");
select upper("666abc");
select replace("77acwing","77ac","77av");
select substring("76543721",1,3);
-- 765 第一位下标为1

3.日期函数

select current_date();
select current_time();
select current_timestamp();
-- 可以用year()平替
select extract(year from '2022-04-05 06:55:57');
-- 取日期
select date('2022-04-05 06:55:57');
-- 取时间
select time('2022-04-05 06:55:57');
-- 取小时
select hour('2022-04-05 06:55:57');

4.转换函数 转换数据类型

自定义函数

作者:ydssx7

出处:https://www.cnblogs.com/ydssx7/p/16156009.html

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

posted @   ydssx  阅读(26)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
more_horiz
keyboard_arrow_up dark_mode palette
选择主题
点击右上角即可分享
微信分享提示