Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 16622
  • Last Modified:

difference between single row function and multi row function

Can anybody explain me what are single row and multi row function with example?
Differences between single row function and multi row function.
0
nag0452
Asked:
nag0452
  • 2
2 Solutions
 
seazodiacCommented:
single-row function: "functions return a single result row for every row of a queried table or view. "
Multiple row functions:  "functions return a single result row based on groups of rows, rather than on single rows."

an example using scott schema emp table:


select empno, ename, to_char(sal, '9,999.99') from emp; --here to_char is a single row function


select deptno, sum(sal) from emp group by deptno; --here sum() is a multiple row function.


0
 
DanielztCommented:

one more:

SQL-FUNCTIONS

    A SQL function is similar to an operator in that it manipulates data
    items and returns a result.  Functions differ from operators in the
    format in which they appear with their arguments.  This format
    allows them to operate on zero, one, two, or more arguments:
 
function(argument, argument, ...)
 
    If you call a function with an argument of a datatype other than the
    datatype expected by the function, Oracle implicitly converts the
    argument to the expected datatype before performing the function.
 
    If you call a function with a null argument, the function
    automatically returns null.  The only functions that do not follow
    this rule are CONCAT, REPLACE, DUMP. and NVL.
 
    Do not design your applications to rely on Oracle either to evaluate
    or to not evaluate all arguments to a function.
 
    Note:  You can call a Stored PL/SQL function anywhere that you
    can call a SQL function.  Refer to your PL/SQL documentation for
    information on how to construct a Stored PL/SQL function for use
    in a SQL statement.
 
    Functions are of these general types:
 
    * single row (or scalar) functions
    * group functions (or aggregate) functions
 
    These functions differ in the number of rows upon which they act.  A
    single row function returns a single result row for every row of a
    queried table or view, while a group function returns a single
    result row for a group of queried rows.
 
    Single row functions can appear in select lists (provided the SELECT
    statement does not contain a GROUP BY clause), WHERE clauses, START
    WITH clauses, and CONNECT BY clauses.
 
    Group functions can appear in select lists and HAVING clauses.  If
    you use the GROUP BY clause in a SELECT statement, Oracle divides
    the rows of a queried table or view into groups.  In a query
    containing a GROUP BY clause, all elements of the select list must
    be either expressions from the GROUP BY clause, expressions
    containing group functions, or constants.  Oracle applies the group
    functions in the select list to each group of rows and returns a
    single result row for each group.  If you omit the GROUP BY clause,
    Oracle applies group functions in the select list to all the rows in
    the queried table or view.  You can also use group functions in a
    HAVING clause in the statement to restrict the result rows returned.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now