MySQL学习----MySQL函数(一)----09MySQL数学函数和聚合函数
来源:互联网 发布:云计算 云服务 编辑:程序博客网 时间:2024/05/22 06:14
-- MySQL数学函数和聚合函数
-- ABS取绝对值
select abs(-5);
-- celling 取刚好大于这个数的整数
select ceiling(5.8);
-- floor 取刚好小于这个数的整数
select floor(5.8);
-- greatest取数组中最大的数
select greatest(1,9,5,2,6,4);
-- least取数组中最小的数
select least(1,9,5,2,6,4);
-- mod除余运算
select mod(2,3);
-- pi函数 3.141593
select pi();
-- 产生一个随机数
select rand();
select rand(2);
-- 四舍五入
select round(10.235456,2);
-- 直接截断
select truncate(10.235456,2);
-- 没有布尔类型,用1表示正数,-1表示负数,0表示0
-- sign判断正数,负数 0
select sign(-1);
select sign(1);
select sign(0);
-- 三角函数
select cos(1);
-- 乘方
select pow(2,3);
-- 开方
select sqrt(4);
-- age字段平均数
select * from table1;
select avg(age) from table1;
-- -- 求和
select sum(age) from table1;
-- 求最大值,最小值
select max(age) from table1;
select min(age) from table1;
-- 值的个数
select count(age) from table1;
-- ABS取绝对值
select abs(-5);
-- celling 取刚好大于这个数的整数
select ceiling(5.8);
-- floor 取刚好小于这个数的整数
select floor(5.8);
-- greatest取数组中最大的数
select greatest(1,9,5,2,6,4);
-- least取数组中最小的数
select least(1,9,5,2,6,4);
-- mod除余运算
select mod(2,3);
-- pi函数 3.141593
select pi();
-- 产生一个随机数
select rand();
select rand(2);
-- 四舍五入
select round(10.235456,2);
-- 直接截断
select truncate(10.235456,2);
-- 没有布尔类型,用1表示正数,-1表示负数,0表示0
-- sign判断正数,负数 0
select sign(-1);
select sign(1);
select sign(0);
-- 三角函数
select cos(1);
-- 乘方
select pow(2,3);
-- 开方
select sqrt(4);
-- age字段平均数
select * from table1;
select avg(age) from table1;
-- -- 求和
select sum(age) from table1;
-- 求最大值,最小值
select max(age) from table1;
select min(age) from table1;
-- 值的个数
select count(age) from table1;
0 0
- MySQL学习----MySQL函数(一)----09MySQL数学函数和聚合函数
- MySQL函数学习笔记一:数学函数
- mysql聚合函数和分组
- mysql函数--数学函数
- MySQL聚合函数和加密函数
- Mysql聚合函数简介
- MySQL中的聚合函数
- mysql聚合函数
- mysql(三、聚合函数)
- Mysql 使用聚合函数
- mysql聚合函数
- MySQL聚合函数
- MySQL聚合函数
- Mysql-聚合函数
- Mysql之聚合函数
- MySQL 学习<四> MySQL函数简介(数学函数、字符串函数、日期和时间函数)
- MySQL 学习总结-聚合函数总结
- MySQL学习之聚合函数查询
- [LeetCode] Length of Last Word - 最后一个单词的长度
- mybatis中jsp获取不同表字段显示
- JavaScript显式类型转换与隐式类型转换
- HashMap详解
- C++动态定义二维数组
- MySQL学习----MySQL函数(一)----09MySQL数学函数和聚合函数
- MySQL学习----MySQL函数(一)----10MySQL字符串函数
- MySQL学习----MySQL函数(一)----11MySQL日期和时间函数
- 数据结构实践——顺序表应用
- UVA12545 Bits Equalizer(脑洞)
- 如何查看Undo和Temp表空间中的会话
- 关于eclipse(64位)下aptana插件安装报错问题解决
- MapReduce的容错机制
- leetcode 70 Climbing Stairs(难易度:Easy)