January 12th, 2009

Introduction to Column Functions, Part 3 of 3

Posted by admin in J. Column Functions

Because a column function returns only a single value in the result table, a column function can only be included with other column functions, and can not be included with a condition that would result in many rows.

 <– is an invalid operation.

The one exception to this rule is a GROUP BY clause, where you use the GROUP BY column in the SELECT.

          SELECT COST_PCT, AVG(PRICE)
            FROM INVENTORY_TBL
            GROUP BY COST_PCT;

You can not nest column functions.

          SELECT SUM(MIN(QTY))           <-- is an invalid operation.

Oracle allows some exceptions to this rule.

You can use more than one column function in a SELECT statement.

          SELECT MIN(QTY), MAX(QTY)      <-- is ok.

You can not place a column function in a WHERE clause.

          SELECT DESCRIPTION
            FROM INVENTORY_TBL
           WHERE PRICE = MAX(PRICE)      <-- is an invalid operation.

Comments are closed.

Sorry, the comment form is closed at this time.