当前位置:网站首页>Mysql常用函数(汇总)
Mysql常用函数(汇总)
2022-07-26 22:38:00 【·~简单就好】
Mysql常用函数(汇总)
一、常用数字处理函数
| 常用数字处理函数 | 函数名称 | 执行sql | 返回结果 |
|---|---|---|---|
| ABS(x) | 返回x的绝对值 | SELECT ABS(-1); | 1 |
| AVG(expression) | 求平均值 | select AXG(age) from student | 返回年龄的平均值 |
| CEIL(x) | 大于x的最小整数 | SELECT CEIL(1.5); | 2 |
| CEILING(x) | 大于x或者等于x的最小整数 | SELECT CEILING(1.5); | 2 |
| FLOOR(x) | 小于x的最小整数 | SELECT FLOOR(1.5); | 1 |
| MAX(age) | 最大值 | SELECT MAX(age) AS maxAge FROM Student; | 返回最大年龄 |
| POWER(x,y) | 返回 x 的 y 次方 | SELECT POWER(2,3); | 返回2的3次方 |
| RAND() | 返回 0 到 1 的随机数 | ||
| SUM(expression) | 返回指定字段的总和 | SELECT SUM(age) FROM Student; | 年龄总和 |
| SQRT(x) | 返回x的平方根 | SELECT SQRT(25); | 返回5 |
| TRUNCATE(x,y) | 数值x保留y位 | SELECT TRUNCATE(1.23456,3); | 返回1.234 |
| GREATEST(expr1, expr2, …) | 返回列表中的最大值 | SELECT GREATEST(3, 12, 34, 8, 25); | 返回34 |
| LEAST(expr1, expr2, …) | 返回列表中的最小值 | SELECT LEAST(3, 12, 34, 8, 25); | 返回3 |
二、常用日期函数
1、CURDATE()/CURRENT_DATE()返回当前日期
SELECT CURDATE();
SELECT CURRENT_DATE();
---- 返回返回当前日期
2、CURRENT_TIME()/CURTIME()返回当前时间
SELECT CURRENT_TIME();
---- 返回17:40:45
3、CURRENT_TIMESTAMP()返回当前日期和时间
SELECT CURRENT_TIMESTAMP();
---- 返回2022-07-26 17:41:32
4、ADDDATE(d,n)计算起始日期 d 加上 n 天的日期
SELECT ADDDATE("2017-06-15", INTERVAL 10 DAY);
---- 返回2017-06-25
5、ADDTIME(t,n)时间 t 加上 n 秒的时间
SELECT ADDTIME('2011-11-11 11:11:11', 5);
---- 返回2011-11-11 11:11:16
6、DATE()从日期或日期时间表达式中提取日期值
SELECT DATE("2017-06-15 11:11:16");
---- 返回2017-06-15
7、DAY(d)返回日期值 d 的日期部分
SELECT DAY("2017-06-15");
边栏推荐
- Flink SQL (II) Kafka connector
- Deep learning of parameter adjustment skills
- TypeScript(tsconfig.json)
- Openharmony quick start
- Leetcode - linked list
- C语言 求素数、闰年以及最小公倍数最大公约数
- Codeforces C1. Simple Polygon Embedding
- 放图仓库-2(函数图像)
- Matlab based medical imaging technology filtering backprojection simulation, including direct backprojection, S-L filtering, R-L filtering, LeWitt filtering
- Convolutional neural network -- lenet (pytorch Implementation)
猜你喜欢

Recbole use 1

Matlab simulation of image reconstruction using filtered back projection method

蒙着头配置deeplabcut2

6_梯度下降法(Gradient Descent)
![[Qt]容器类、迭代器、foreach关键字](/img/88/d9d5be096009b4e5baa0966e6f292c.jpg)
[Qt]容器类、迭代器、foreach关键字

20220720折腾deeplabcut2

The crawler parses the object of the web page. Element name method

Shufflenet series (2): explanation of shufflenet V2 theory

Today's 20220719 toss deeplobcut

运算符重载
随机推荐
Anaconda = > pycharm=> CUDA=> cudnn=> pytorch environment configuration
Based on the theoretical principle and simulation results of MATLAB spherical decoding, compare 2norm spherical decoding, infinite norm spherical decoding, ML detection
20220720折腾deeplabcut2
Deep learning of parameter adjustment skills
20220720 toss deeplobcut2
"Syntaxerror: future feature annotations is not defined"
Flink SQL (II) Kafka connector
信号与系统学习零输入响应
Matlab based medical imaging technology filtering backprojection simulation, including direct backprojection, S-L filtering, R-L filtering, LeWitt filtering
[Qt]元对象系统
C语言 关机小程序
View where Anaconda created the environment
Helicopter control system based on Simulink
放图仓库-Tsai
Leetcode - hash table
MySQL optimization
PTA 7-4 small generation (DFS)
Transpose convolution correlation
在pycharm中部署yolov5报错问题
Codeforces C1. Simple Polygon Embedding