Aggregate functions of Oracle Common functions

Source: Internet
Author: User

Aggregation functions

------------------------------------------aggregate function---------------------------------------------

--1:avg (distinct| All)

All means that all values are averaged, and distinct only averages the different values.

SELECT AVG (SAL) from SCOTT. EMP;

SELECT AVG (DISTINCT SAL) from SCOTT. EMP;

--2:max (distinct| All)

The maximum value, all represents the maximum value for all values, distinct represents the maximum value for the different values, the same only once

(plus no query results consistent, I do not know what the use of distinct, unlike the AVG and other aggregation functions)

SELECT MAX (DISTINCT SAL) from SCOTT. EMP;

SELECT MAX (SAL) from SCOTT. Emp

--3:min (distinct| All)

The minimum value, all means the minimum value for all values, distinct represents the minimum value for different values, the same only once

SELECT MIN (SAL) from SCOTT. EMP;

SELECT MIN (DISTINCT SAL) from SCOTT. EMP;

--4:stddev (Distinct|all)

Standard deviation, all means a standard deviation for all values, distinct means only the standard deviation for different values

SELECT STDDEV (SAL) from SCOTT. EMP;

SELECT STDDEV (DISTINCT SAL) from SCOTT. EMP;

--5:variance (distinct| All)

Covariance all means that all values are covariance, distinct means that only different values are evaluated for covariance

SELECT VARIANCE (SAL) from SCOTT. EMP;

SELECT VARIANCE (DISTINCT SAL) from SCOTT. EMP;

--6:sum (distinct| All)

Sum all means summing all values, distinct means summing only different values (the same value is only taken once)

SELECT SUM (SAL) from SCOTT. EMP;

SELECT SUM (DISTINCT SAL) from SCOTT. EMP;

--7:count (distinct| All)

The number of records and data. All records, arrays are counted, distinct only for the different values (the same value is only taken once)

SELECT COUNT (SAL) from SCOTT. EMP;

SELECT COUNT (DISTINCT SAL) from SCOTT. EMP;


----8:median
To find the median number

SELECT MEDIAN (SAL) from SCOTT. EMP;

SELECT MEDIAN (DISTINCT SAL) from SCOTT. EMP; --Error: The DISTINCT option is disabled in this function.


----------------------------------------------------------------------------------------------

Aggregate functions of Oracle Common functions

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.