Mysql common aggregate functions detailed _mysql

Source: Internet
Author: User

One, AVG

AVG (COL)

Returns the average of the specified column

Two, COUNT

COUNT (COL)

Returns the number of non-null values in the specified column

Third, Min/max

Min (col): Returns the minimum value of the specified column

Max (COL): Returns the maximum value for the specified column

Four, SUM

SUM (COL)

Returns the sum of all the values of the specified column

Five, Group_concat

Group_concat ([DISTINCT] expr [, expr ...]
[ORDER BY {Unsigned_integer | col_name | expr}
[ASC | DESC] [, col_name ...]]
[SEPARATOR Str_val])

Returns the result of a combination of column-value joins that belong to a group

SELECT Id,group_concat (name) from my_table GROUP by ID;

SELECT id,group_concat (name separator '; ') From my_table GROUP by ID;

SELECT Id,group_concat (name order by ID) from my_table GROUP by ID;

SELECT Id,group_concat (name ORDER by ID separator '; ') From my_table GROUP by ID;

The above is a small series for everyone to bring the MySQL common aggregate function detailed content, I hope that we support cloud Habitat Community ~

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.