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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Question about finding maximum and minimum

Re: Question about finding maximum and minimum

From: <thtsang_at_my-dejanews.com>
Date: Tue, 08 Dec 1998 05:42:38 GMT
Message-ID: <74ie8f$2ac$1@nnrp1.dejanews.com>


(To KeyStroke and Tomas) Thank you very much for your help. However, both method did not work .

for KeyStroke's method,
> select t1.a
> from t t1
> where t1.a >= a1 and
> t1.a <= a2
> and t1.a in
> (select min(t1.a) from t t1
> union
> select max(t1.a) from t t1)

This did not work because the subquery(ies?) only select the max / min from t. If they are not in the range a1 and a2, nothing will be selected. This method works only when a1 < min(t1.a) and a2 > max(t2.a) :)

for Tomas's Method
> select t1.a
> from t t1
> where t1.a >= a1 and
> t1.a <= a2
> and t1.a in ( select min(t1.a)
> from t1 where t1.a between a1 and a2
> union all
> select max(t1.a)
> from t1 where t1.a between a1 and a2)

This did not work because a1 and a2 cannot appear in the added part.

Anyway, thank you very much!!

Anthony

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Mon Dec 07 1998 - 23:42:38 CST

Original text of this message

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