Oracle _ Common grouping Functions

Source: Internet
Author: User

Oracle _ Common grouping Functions
Zookeeper

Oracle _ Common grouping Functions
① Grouping Function
1. max (column): calculates the maximum value, which is not required for the data type. Any data type can be used.
2. min (column): calculates the minimum value and has no requirements on the data type. Any data type can be used.
3. avg (column): returns the average value of column not null, which has requirements on the Data Type and can only be for the number type (number type)
4. sum (column): returns the sum of columns not null. It has requirements on data types and can only be set to number (number type)
5. count (column): return the number of records whose column is not null. No data type is required. Any data type can be used.

Note: Group functions ignore null values.
COUNT (DISTINCT expr) returns the total number of records that are not empty and repeat

② Grouping
Group data: group by clause syntax
You can use the group by clause to divide data in a table into several groups.
All columns not included in the GROUP function in the SELECT list should be included in the group by clause.
Columns included in the group by clause do not need to be included in the SELECT list
All columns included in the select list and not included in GROUP functions must be included in the group by clause.

You cannot use group functions in the WHERE clause.
You can use group functions in the HAVING clause.

③ Filter group: HAVING clause
Use HAVING to filter groups:
1. rows have been grouped.
2. Group functions are used.
3. Groups that meet the conditions in the HAVING clause will be displayed.

④ Group function nesting
Max (avg (salary ))

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.