Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Question about finding maximum and minimum
(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
![]() |
![]() |