Solved

difference between single row function and multi row function

Posted on 2004-03-31
5
13,035 Views
Last Modified: 2012-06-21
Can anybody explain me what are single row and multi row function with example?
Differences between single row function and multi row function.
0
Comment
Question by:nag0452
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
seazodiac earned 63 total points
ID: 10723556
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
 
LVL 8

Expert Comment

by:Danielzt
ID: 10723663
0
 
LVL 8

Assisted Solution

by:Danielzt
Danielzt earned 62 total points
ID: 10723687

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to take different types of Oracle backups using RMAN.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question