MySQL's aggregation function

Source: Internet
Author: User

1.AVG ()

Usage: Averaging

Example:

Mysql> Select *  fromT1;+----+------+----------+---------+-------+-------+|Id|Name|Password|test001|Test3|Test4|+----+------+----------+---------+-------+-------+|  2 | 1    | 1        | 1       | 1     | 1     ||  3 | 3    | 4        | 5       | 6     | 7     ||  4 | 3    | 4        | 5       | 6     | 7     ||  5 | 3    | 4        | 5       | 6     | 7     ||  6 | 3    | 4        | 5       | 6     | 7     ||  7 | 3    | 4        | 5       | 6     | 7     ||  8 | 3    | 4        | 5       | 6     | 7     ||  9 | 3    | 4        | 5       | 6     | 7     || Ten | 3    | 4        | 5       | 6     | 7     |+----+------+----------+---------+-------+-------+9Rowsinch Set(0.00sec) MySQL> Select AVG(ID) fromT1;+---------+| AVG(ID)|+---------+|  6.0000 |+---------+1Rowinch Set(0.00Sec

2.COUNT ()

Usage: Record number of bars

Example:

Mysql> Select COUNT(ID) fromT1;+-----------+| COUNT(ID)|+-----------+|         9 |+-----------+1Rowinch Set(0.00Sec

3.MAX ()

Usage: Returns the maximum value

Example:

Mysql> Select MAX(ID) fromT1;+---------+| MAX(ID)|+---------+|      Ten |+---------+1Rowinch Set(0.01Sec

4.MIN ()

Usage: Returns the minimum value

Example:

Mysql> Select MIN(ID) fromT1;+---------+| MIN(ID)|+---------+|       2 |+---------+1Rowinch Set(0.00Sec

5.SUM ()

Usage: Sum

Example:

Mysql> Select SUM(ID) fromT1;+---------+| SUM(ID)|+---------+|       Wu |+---------+1Rowinch Set(0.00Sec

Others: MD5 (), PASSWORD ()

Mysql> SelectMD5 ('MYSQL');+----------------------------------+|MD5 ('MYSQL')|+----------------------------------+|14498b83dd1667a0c78f4fdaf5afbf4b|+----------------------------------+1Rowinch Set(0.00sec) MySQL> SelectPASSWORD ('MYSQL');+-------------------------------------------+|PASSWORD ('MYSQL')|+-------------------------------------------+| *a97af8e14502c1b988202fb7b96cf565b6523f9d|+-------------------------------------------+1Rowinch Set(0.00sec) MySQL> SelectEncypt ('MYSQL'); ERROR1305(42000):FUNCTIONTest. Encypt does notExistmysql> SelectENCRYPT ('MYSQL');+------------------+|ENCRYPT ('MYSQL')|+------------------+| NULL             |+------------------+1Rowinch Set(0.03Sec

MySQL's aggregation function

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.