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.