Learning Oracle (XI) aggregate function

AVG () averaging

- query a column average of 
the SELECT  AVG (column) the FROM list

 COUNT () query number of

- Query the Number of all records 
SELECT  COUNT ( * ) from the table; 

- the value corresponding to the query is not the Number of columns empty record 
SELECT  COUNT (column) from the table; 

- query corresponding to the number of columns of records will not be repeated 
SELECT  COUNT ( DISTINCT column) from the table;

FIRST () The first query

- expression of the oracle first () function 
SELECT 
    columns 
FROM 
    table 
the ORDER  BY 
    columns of the ASC 
the WHERE 
    ROWNUM <=  . 1 ;

 LAST () inquiry last

- expression of the oracle last () function of 
the SELECT 
    column_name 
the FROM 
    table_name 
the ORDER  BY 
    column_name DESC 
the WHERE 
    ROWNUM <=  . 1 ;

MAX () maximum value   MIN () Min

- the maximum value of the designated column in 
the SELECT  MAX (column) the FROM list; 

- minimum specified column 
the SELECT  MIN (column) the FROM table;

SUM () the value of the specified column statistics

- Statistical specified total number of columns 
the SELECT  SUM (column) the FROM table;

BY the GROUP () (in conjunction with a normal aggregation function for statistical) packet

- group statistics 
SELECT aggregate functions (column)
 the FROM table
 the GROUP  BY columns;

The HAVING (each group of the filtered data packets)

- HAVING and where usage is similar to 
PS : increase the HAVING clause because the WHERE keyword can not be used with an aggregate function
PS : HAVING clause allows us to filter the data in each group after the grouping
SELECT column, aggregate functions (column) the FROM table WHERE condition the gROUP BY column HAVING aggregate function (column) conditions; - this line according to the purpose of screening function again after polymerization packet

 

Guess you like

Origin www.cnblogs.com/riches/p/11348467.html