-
Junior Member
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.
-
Expert Member
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
-
Re: Different Outputs for Max() Function
select max(rowid) from emp will not return multiple rows .
-
Junior Member
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
-
Junior Member
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
-
Forum Rules