Oralce common SQL functions (5) Aggregate functions

Source: Internet
Author: User


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.
 

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.