count,sum,avg,max,min__mysql学习笔记
来源:互联网 发布:神仙道懒娃 源码 编辑:程序博客网 时间:2024/06/13 13:15
函数
Count
Sum
Max
Min
Avg
唔,我开始看原版的了
1,count
Used tocount rows or valudes of a column that do not contain a NULL value;
Could beused with the DISTINCT;
All(opposite of DISTINCT) is the default;
Plus:count (*) counts all the rows of a table includingduplicates, whether a NULL value iscontained in a column or not ;
select Count [(*) | (DISTINCT | ALL)] (COLUMN NAME) from table_name;
Attention:COUNT is used to count rows, not values!!!
Count(salary) from table_name;
Count (all salary) from table_name;
Count(*) from table_name;//If we use *,don't write column_name!!!
ANY datatype is OK;
2,sum
Returns atotal on the values of a column for a group of rows;
Can beused with distinct,only the distinct rows are totaled;
Select sum([DISTINCT]COLUMN_NAME) FROM TABLE_NAME;
The valudemust be numeric, or there must be somethingwrong;
3,avg
SELECT AVG ([DISTINCT]COLUMN_NAME) FROM TABLE_NAME;
Selectavg(salary),avg(money) from table_name;//it's ok;
Attention:insome implementions,the results of your query might be truncatedto the precision of the data type;
4,max,min
Return themaximum value from the values of a column in a group of rows;
NULL values are ignored for both max and min;
Distinctcommand is an option but useless;
Select max([distinct]column_name) from table_name;
MAX andMIN can also be used on character datad.Most commonly your database collationis set to a dictionary order ,so the results arerankedaccording to that.
Attention:whenusing aggregate funcitons with the DISTINCTcommand ,our query might not return the desired result;
Wecan use them in this way:
Selectcount(C_1),sum(C_2),sum(C_3)/count (C_4) c_4
Fromtable_name;//c_4 is a column alias for the computation.
Itshows:
Count(C_1) sum(C_2) c_4
XXX XXX XXXx
- count,sum,avg,max,min__mysql学习笔记
- oracle学习笔记(二)substr,nvt,max,min,avg,sum,count,group,having
- MySQL学习足迹记录10--汇总数据--MAX(),MIN(),AVG(),SUM(),COUNT()
- 聚合函数(sum,count,max,avg等)ZT
- 常用集函数,count(),sum(),avg(),max(),min()
- linq to sql 用法 ----- count/sum/min/max/avg
- MySQL之汇总数据(AVG,COUNT,MAX,MIN,SUM)
- mysql之avg(),count(),min()/max(),sum()函数
- mysql之count,max,min,sum,avg,celing,floor
- LINQ to SQL Count/Sum/Min/Max/Avg Join
- HQL中的聚合函数:count()sum()avg()max()min()
- 12 聚集函数:avg() count() max() min() sum()
- oracle中的聚合函数count、max、min、sum、avg等等
- 常用集函数,count(),sum(),avg(),max(),min()
- mysql sum Count AVG
- [笔记] awk命令计算sum, min, max, avg
- SQL中count()/max() /min()/sum()avg()/sum()等函数用法
- Hibernate 使用 count(*)、avg、sum
- ubuntu mysql 执行sql文件
- bzoj1072 [SCOI2007]排列perm
- 斯坦福cs224d(深度学习在自然语言处理上的应用)Lecture 2
- 【算法研究与实现】最小二乘法直线拟合
- 17:Letter Combinations of a Phone Number(字母组合的电话号码)
- count,sum,avg,max,min__mysql学习笔记
- C++中 typename 和 class 的区别
- SpringMVC小结
- Search a 2D Matrix II(leetcode)
- 重载 重写
- 最简单的排序——选择排序
- 城市交通
- spring,springmvc,mybatits集成实例--后台分页查询
- idea安装与使用