Tuesday, September 29, 2009

Using the Group Functions

What Are Group Functions ?
  • Group functions operate on sets of rows to give one result per group.
Types of Group Functions :
  • AVG
  • COUNT
  • MAX
  • MIN
  • SUM

Group Functions : Syntax
  • SELECT [column,] group_function(column), ... FROM table [WHERE condition] [GROUP BY column] [ORDER BY column];

Nesting Functions

SELECT ename, UPPER(SUBSTR (ENAME, 1, 8) || '_US') FROM emp WHERE deptno = 10;
The slide example displays the last names of employees in department 10.

The evaluation of the SQL statement involves three steps:

  • – The inner function retrieves the first eight characters of the last name.
  • Result1 = SUBSTR (ENAME, 1, 8)
  • – The outer function concatenates the result with _US.
  • Result2 = Result1 || '_US'
  • – The outermost function converts the results to uppercase.

Followers