Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: strange behaviour (query) ...
>I want to determine the 2nd greatest number. Why does
>
>SELECT MAX(a)
>FROM banane MINUS ( SELECT MAX(a) AS x FROM banane );
>
>not work ? Why are 3 SELECTs necessary ?
The MINUS operator works on two sets:
The first is built by "SELECT MAX(a) FROM banane" and will
contain one number: the maximum value in banane.
The second is built by "SELECT MAX(a) AS x FROM banane" and will
also contain one number: the maximum value in banane.
As you see, both sets contain the same value. Subtracting the values in the second set from the values in the first set will leave no records in the first set.
Regards,
Stefan Deisz.
Name :G.R.S. Deisz Phone :+31-50-5855954 E mail :G.R.S.Deisz_at_PTT-Telecom.Unisource.NL DISCLAIMER:This statement is not an official statement from, nor does it represent an official position of, PTT Telecom BV.Received on Fri Feb 28 1997 - 00:00:00 CST