Aggregation function MYSQL -------

# Aggregate function
sum()  avg()   max()   min()   count()
Statistics of all tuples attributes corresponding data output line

/ * Can be used with other functions use
For example: the average retained two decimal places: ROUND (AVG (), 2)
*/

- type of the parameter
  SUM (), AVG () General process numeric
  MAX (), MIN () processing numeric, character, and dates
  COUNT () is a statistical non-null column names, if * is counting the number of all tuples (containing NULL)
  
  
- whether to ignore NULL values  
  Above functions ignore NULL values
 
 
- can be used with and distinct
 SELECT SUM(DISTINCT salary) from employees;
 
 
 
- COUNT () function in detail
   1 .Select COUNT (column name) FROM employees; (NULL not count)
   2 .Select COUNT (* ) FROM employees; (NULL counts)
   3 .Select COUNT ( 1 ) the FROM the Employees; (and Similarly a second, generally using the second embodiment)
  

 

Guess you like

Origin www.cnblogs.com/god-for-speed/p/10927670.html