Oracle grouping Functions

Source: Internet
Author: User

AVG ([distinct | all] x) [function] calculates the average value of column x in the selected row in the data table. [Parameter] all indicates the average value for all values. distinct evaluates the average value for different values only. The default value is all. If the distinct or all parameter is available, spaces and x (columns) are required). [Parameter] x, which can only be a numeric field [Return] numeric value [Example] environment: create table table3 (xm varchar (8), sal number )); insert into table3 values ('gao', 1111.11); insert into table3 values ('gao', 1111.11); insert into table3 values ('zhu', 5555.55); commit; execution statistics: select avg (distinct sal), avg (all sal), avg (sal) from table3; Result: 3333.33 2592.59 2592.59
SUM ([distinct | all] x) [function] calculates the total value of column x of the selected row in the data table. [Parameter] "all" indicates the sum of all values. "distinct" evaluates the sum of all values only for different values. The default value is "all". If the distinct or all parameter exists, A space is required to separate x (column. [Parameter] x, which can only be a numeric field [Return] numeric value [Example] environment: create table table3 (xm varchar (8), sal number )); insert into table3 values ('gao', 1111.11); insert into table3 values ('gao', 1111.11); insert into table3 values ('zhu', 5555.55); commit; execution statistics: select SUM (distinct sal), SUM (all sal), SUM (sal) from table3; Result: 6666.66 7777.77 7777.77
VARIANCE ([distinct | all] x) [function] calculates the VARIANCE of column x selected from the data table. [Parameter] "all" indicates variance for all values. "distinct" only evaluates variance for different values. The default value is "all". If distinct or all is input, spaces and columns are required). [Parameter] x, which can only be a numeric field [Return] numeric value [Example] environment: create table table3 (xm varchar (8), sal number )); insert into table3 values ('gao', 1111.11); insert into table3 values ('gao', 1111.11); insert into table3 values ('zhu', 5555.55); commit; execution statistics: select VARIANCE (distinct sal), VARIANCE (all sal), VARIANCE (sal) from table3; Result: 9876523.4568 6584348.9712 6584348.9712
Count (* | [distinct | all] x) [function] calculates the total value of column x in the selected row of the data table. [Parameter] * Indicates statistics on all rows that meet the condition. No matter whether it is repeated or NULL (NULL) all indicates statistics on all values, by default, all distinct is used for statistics only on different values. If the distinct or all parameter exists, a space must be separated from x (Column). NULL values are ignored ). [Parameter] x, which can be a number, character, date type, and other types of fields [Return] numeric value count (*) = sum (1) [Example] environment: create table table3 (xm varchar (8), sal number (7,2); insert into table3 values ('gao', 1111.11); insert into table3 values ('gao ', 1111.11); insert into table3 values ('zhu', 5555.55); insert into table3 values ('', 1111.11); insert into table3 values ('zhu', 0); commit; execution statistics: select count (*), count (xm), count (all xm), count (distinct sal), count (all sal), count (sal ), sum (1) from table3; Result: 5 4 4 3 5 5
MIN ([distinct | all] x) [function] calculates the maximum value of column x in the selected row in the data table. [Parameter] "all" indicates the maximum value for all values. "distinct" is the maximum value for different values only. The default value is "all". If the distinct or all parameter is available, spaces and x (columns) are required). [Parameter] x, which can be a number, character, or date field. [Return] corresponds to the x field type. Note: The NULL value (NULL) is ignored. [Example] environment: create table table3 (xm varchar (8), sal number (7,2); insert into table3 values ('gao', 1111.11); insert into table3 values ('gao ', 1111.11); insert into table3 values ('zhu', 5555.55); insert into table3 values ('', 1111.11); insert into table3 values ('zhu', 0); commit; execution statistics: select MIN (distinct sal), MIN (xm), MIN (distinct xm), MIN (all xm) from table3; Result: 0 gao

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.