MySQL: function 4: Aggregate functions used with group

Source: Internet
Author: User

Unless otherwise specified, Aggregate functions ignore null records.

Unless otherwise specified, the aggregate function returns NULL if no matching record is found (the record set is empty.

If you use an aggregate function in a statement that does not use group by, it is equivalent to grouping all rows.

 

Aggregate (Group) Functions

Name Description
AVG () Return the average value of the argument
Bit_and () Return bitwise AND
Bit_or () Return bitwise OR
Bit_xor ()(V4.1.1) Return bitwise XOR
Count (distinct) Return the count of a number of different values
Count () Return a count of the number of rows returned
Group_concat ()(V4.1) Return a concatenated string
Max () Return the maximum value
Min () Return the minimum value
Stddev_pop ()(V5.0.3)Stddev ()STD () Return the population standard deviation
Stddev_samp ()(V5.0.3) Return the sample standard deviation
Sum () Return the sum
Var_pop ()(V5.0.3)Variance ()(V4.1) Return the population standard variance
Var_samp ()(V5.0.3) Return the sample variance

 

Bit_and () If no rows are returned, it is the largest unsigned bigint INTEGER:18446744073709551615

Bit_or () and bit_xor () are 0 if no rows are returned.

Count (*) returns the data of all rows, including null. If no row is returned, it is 0.

Count (expr) returns all non-null data. If no row is returned, it is 0.

Count (distinct expr) returns all non-null data. If no row is returned, it is 0. It is not compatible with SQL standards. standard SQL returns the number of rows of all different data, including null values

 

 

Group by rollup statistical modifier. Equivalent to SQL Server's rollup function!

 

 

MySQL's extension to group by in the standard SQL language: columns not in group by can appear in the select list. In this case, the values of the hidden columns of group by are randomly selected. All group columns whose values correspond to group by should be the same! Unless you want! Similarly, there is having processing. Therefore, if you want to avoid this poor MySQL extension, you can setOnly_full_group_bySQL mode is enabled.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.