Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Question about finding maximum and minimum
Hello,
I have a silly question about SQL statements. I have the following SQL statement:
select t1.a
from t t1
where t1.a >= a1 and
t1.a <= a2
where a1, a2 are 2 variables that are defined somewhere else, so that they cannot be used anywhere else in the SQL statement.
However, I only need the maximum and minimum of the results. That is, the following SQL statement will suit my need:
select max(t1.a), min(t1.a)
from t t1
where t1.a >= a1 and
t1.a <= a2
The problem is that I cannot change anything in the original SQL statement (I know this is silly but I am under such restriction.) What I can do is only adding something at the end. It can involve a sub-query. Also, what makes the problem challenging is that I cannot use a1 and a2 in the thing I add to the end.
Please tell me how to do this, or whether it is impossible to do this in one SQL statement.
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 - 00:27:27 CST
![]() |
![]() |