SQL tutorial | Interview questions | Oracle
Would you like to react to this message? Create an account in a few clicks or log in to continue.

What Are Group Functions?

Go down

What Are Group Functions? Empty What Are Group Functions?

Post by Micheal Sun Jan 17, 2010 3:05 am

Group functions are functions applied to a group of rows. Examples of group functions are:
COUNT(*) - Returns the number of rows in the group.
MIN(exp) - Returns the minimum value of the expression evaluated on each row of the group.
MAX(exp) - Returns the maximum value of the expression evaluated on each row of the group.
AVG(exp) - Returns the average value of the expression evaluated on each row of the group.
How To Use Group Functions in the SELECT Clause?
If group functions are used in the SELECT clause, they will be used on the rows that meet the
query selection criteria, the output of group functions will be returned as output of the query. The
following select statement returns 4 values calculate by 4 group functions on all rows of the
"departments" table:
SQL> SELECT COUNT(*), MIN(department_id), MAX(department_id)
FROM departments;
COUNT(*) MIN(DEPARTMENT_ID) MAX(DEPARTMENT_ID)
---------- ------------------ ------------------
27 10 270

Micheal
Admin

Posts : 243
Join date : 2010-01-10

http://sql-tutorial.co.cc

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum