Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: MIN and MAX function between colums
> Min and Max calculated something for one column. Does that also between
> columns like
>
> min(column1, column2) ?
select greatest( col1, col2 ) from tab;
gives for each row the max-value for these 2 columns.
select least( col1, col2 ) from tab;
gives you for each row the min-value for these 2 columns.
You can use more than 2 values in these functions. And you can select the overal min/max-value for the table:
select max( greatest( col1, col2 ) ) from tab; select min( least( col1, col2 ) ) from tab;
Regards, Stephan Received on Mon Oct 29 2001 - 07:57:44 CST