Group functions operate on group of rows and return one value for the ENTIRE GROUP. As a group is consdered the entire table or just some portions of the table grouped by some common atribute.
Group functions are:
COUNT, MAX, MIN, AVG, SUM, DISTINCT
COUNT - It returns the number of rows in the query. For example: we want to know number of employees wich have salary = 10000
What will happen if in the group are rows with NULL values? They will not be considered!!!
For example: We have in the entire table 107 rows, but only 35 from them are with non-null values in collumn commission_pct
DISTINCT - we can use it to retrieve only unique data entries.
Example:
There will be selected just 57 rows. (all duplicate values will be ignored)
AVG - it returns the average value of the column or expression. For example:
As we can see from the examples, the general syntax from the AVG functions is:
AVG([DISTINCT] EXPRESSION)
MAX Function - it will return the highest number (when operation on numeric values), latest date (when operating on date) and the world that appears at last alphabetically ( when operating on char data.
Examples:
MIN Function - it is exactly the opposite of the MAX function. For example:
SUM Function -it returns the sum of values of expression. For more information, pls check ORACLE DOCUMENTATION Examples:
More functions are available under http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions163.htm
No comments:
Post a Comment