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

Home -> Community -> Usenet -> c.d.o.server -> Re: strange behaviour (query) ...

Re: strange behaviour (query) ...

From: Jim Yoshii <yoshii_at_planet.net>
Date: 1997/02/26
Message-ID: <3314E8CC.7DA2@planet.net>#1/1

Michael Agbaglo wrote:
>
> SQL*Plus: Release 3.2.2.0.1 - Production on Mon Feb 24 21:34:09 1997
>
> 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 ?
>
> (Personal Oracle7 Release 7.2.2.3.1)
>
> SQL> SELECT * FROM banane;
>
> A
> ---------
> 1
> 2
> 3
> 5

This query is returning the difference between two equivalent sets resulting in no rows.

>
> SQL> SELECT MAX(a)
> 2 FROM banane MINUS ( SELECT MAX(a) AS x FROM banane );
>
> no rows selected
>
> SQL> SELECT MAX(a)
> 2 FROM ( SELECT * FROM banane MINUS ( SELECT MAX(a) FROM banane));
>
> MAX(A)
> ---------
> 3

How about:

SELECT MAX(a)
 FROM banane where a < (SELECT MAX(a) FROM banane);


         James H. Yoshii
 IntelliTech Business Solutions

        yoshii_at_planet.net


Received on Wed Feb 26 1997 - 00:00:00 CST

Original text of this message

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