Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: SQL Problem

Re: SQL Problem

From: Phineas T. Barnham <PhineasTBarnham_at_PhineasTBarnham.com>
Date: Tue, 24 Apr 2001 20:31:02 +0100
Message-ID: <988140997.5110.0.nnrp-13.9e985e86@news.demon.co.uk>

"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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US