MySQL summary data

Source: Internet
Author: User
Summary data Sometimes the operation of the data table is not the data in the table itself, but a summary of the data in the table, such as the average value of a column of data, maximum, minimum, and so on. For these commonly used data aggregation processes, MySQL provides functions to handle.
SQL aggregation functions
Function Description
COUNT () Returns the number of rows in a column
MAX () Returns the maximum value of a column
MIN () Returns the minimum value of a column
AVG () Returns the average of a column
SUM () Returns the sum of a column value

Example:
First, the Products table is shown below:


Find the average of the Prod_price column looks strange, the original table shows only one line:

To find out the price of all goods of a particular line, such as vend_id =1003;

The Count function is used to determine the number of rows that satisfy a certain condition, with a total of 14 rows in the Products table:

Statistics VEND_ID = 1001 has how many lines:

Max () Find maximum value

Min () Min value

SUM () sums of the sequence values

Aggregating different values counts how many vendors, plus the DISTINCT keyword, only counts the number of different values in that column:

Combining aggregate functions Multiple functions can be used together, more powerful:


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.