Oralce common SQL functions (5) before using aggregate functions, we need to first understand the concept of "grouping". One of the problems we encounter in our work is grouping the retrieved data.
The syntax structure of grouping is very simple, that is, the GROUP field is followed BY the GROUP keyword. For example, we need to query the commodity table and calculate the number of commodities (www.2cto.com) based on the commodity category.
Note that After grouping data, the query result fields after the SELECT statement can only be group fields or aggregate function expressions. Aggregate functions are also called group functions. In some cases, Aggregate functions are also called set functions, its data source generally comes from multiple groups of data, but the returned data is usually a set of data, such as sum, maximum, minimum, and other commonly used Aggregate functions include: 1. the sum function receives a parameter indicating the sum operation for the specified column, for example, to obtain the total number of all items in the item table.
For example, we need to obtain the total quantity of each type of item in the commodity table:
2. The count function www.2cto.com is used to calculate the total number of rows in a specified table column. For example, we need to obtain the total number of records in the product table.
For example, we need to obtain the total number of records of each type of item in the product table.
3. the MAX function is used to obtain the maximum value in a specified column. It also specifies only one parameter to obtain the maximum value for a specified column. If we need to query the price of the most expensive item in the product table
We can also query the prices of the most expensive products in each category.