Why does groupby work with Aggregate functions?

Source: Internet
Author: User
First, the system obtains a result set based on the SELECT statement, such as a detailed table of the first fruit, country of production, and unit price. Then, records with the same group fields are merged into one record based on the group field. At this time, the rest of the statements that do not exist after the GroupBy statement are grouped... first, the system obtains a result set based on the SELECT statement, such as a detailed table of the first fruit, country of production, and unit price. Then, records with the same group fields are merged into one record based on the group field. At this time, the remaining fields that do not exist behind the Group By statement as the basis for grouping may have multiple values, but currently, only one record exists in a Group, a Data lattice cannot be placed into multiple values. Therefore, we need to convert these multi-value columns into single values through some processing, and then put them in the corresponding data lattice, the aggregate function is used to complete this step. That's why these functions are called aggregate functions.
In this sentence, why do we use aggregate functions?

Reply content:

First, the system obtains a result set based on the SELECT statement, such as a detailed table of the first fruit, country of production, and unit price. Then, records with the same group fields are merged into one record based on the group field. At this time, the remaining fields that do not exist behind the Group By statement as the basis for grouping may have multiple values, but currently, only one record exists in a Group, a Data lattice cannot be placed into multiple values. Therefore, we need to convert these multi-value columns into single values through some processing, and then put them in the corresponding data lattice, the aggregate function is used to complete this step. That's why these functions are called aggregate functions.
In this sentence, why do we use aggregate functions?

If there is no aggregate function, the value of the group row in the column not to be group will be the first or last (forgot). If there is an aggregate function, you can set values for those columns based on your needs.

If group by does not work with Aggregate functions, group by does not work.
"Aggregation", as its name implies, aggregates multiple values for some operations, and group by refers to those values.

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.