Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: SQL Problem
"Phil Paston" <p.paston_at_btinternet.com> wrote
> I have a very large oracle table with 4 date columns in it date1 date2
date3
> and date4
>
> Is it possible in sql to write a single query that will give me : the max
of
> date1 and date3 in a new column and the min of date3 and date4 in a
sepatate
> column. or even better :- max of date1 and date3 - min of date3 and
date4
> result in a single column. I don`t want to use a union query if I can help
> it as table is very large and i want to do the calc in one pass if at all
> possible.
>
You can do it with a combination of functions
min() and max()
least() and greatest() - I think that's what they're called
so something like
select least(min(date1), min(date2))...
That's the general gist of it - it's all in the manual.
Sorry if I've got the least/greatest function names wrong. Received on Tue Apr 24 2001 - 14:31:02 CDT