Results 1 to 5 of 5

Thread: Different Outputs for Max() Function

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Answers
    4

    Different Outputs for Max() Function

    Hi,
    Please clarify how does the output of one is a single record/row and how does the output of
    the second one is multiple records/rows

    Let us consider emp table in Oracle

    i wrote

    Q1)select max(sal) from emp

    now the output for the above statement might be 3600(lets say 3600 is the maximum salary)

    Q2)select max(rowid) from emp

    now the output for the above statement is of multiple rows. how does this happen
    I would really appreciate if you could clarify the differences between how does the below work

    a)max(sal)
    b)max(rowid)
    c)y the output of max(sal) is a single row record
    d)y the output of max(rowid) is in multiple rows.


  2. #2
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: Different Outputs for Max() Function

    >>select max(rowid) from emp
    now the output for the above statement is of multiple rows. how does this happen


    Rowid is a unique identifier for each row in a table.No two rows in a table will have same rowid.

    Further Max function is a group function. Group functions always acts on set of records to return one result per each group. No chance to display two records or multiple records.

    So it is impossibe to display multiple rows for folliwing query
    select max(rowid) from emp


  3. #3
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Different Outputs for Max() Function

    select max(rowid) from emp will not return multiple rows .


  4. #4
    Junior Member
    Join Date
    Sep 2007
    Answers
    2

    Re: Different Outputs for Max() Function

    you must having used group by clause in the query.

    select max(rowid) from group by

    in no condition select max(rowid) from return multiple rows, untill 2 queries are joined using UNION, UNION ALL etc


  5. #5
    Junior Member
    Join Date
    May 2008
    Answers
    1

    Re: Different Outputs for Max() Function

    I think there is no case that Select max(rowid) from ; would give more than one single record unless and untill you use a group by clause.

    These group functions works on the group of records. There is one more additional thing which I wan to share is that Max(), Min() and Count() are those group funtions, which can be used for any DATATYPE.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact