Re: SQL Problem. HELP!

From: Lutz Birkhahn <suwelack_at_self.de>
Date: 1997/06/23
Message-ID: <33ADA2CC.143_at_self.de>#1/1


yarivt wrote:
>
> Don't think that the answer that Claudia gave u is the corrent one.

So please tell us why!

> Tell me if she is right.

The query works at least with "Oracle7 Server Release 7.2.3.0.0 - Production Release, PL/SQL Release 2.2.3.0.0 - Production" with all test tables I used.

> Claudia Bock <suwelack_at_self.de> wrote in article <33A83D7B.4504_at_self.de>...
>
> > SELECT S0.territory, S0.name, S0.amount
> > FROM SalesReport S0
> > WHERE 3 > (SELECT COUNT(*) FROM SalesReport S1
> > WHERE S1.territory > S0.territory);

If you want to get the three highest values of column *amount*, you should of course replace "territory" by "amount" in the last line.

Note that the inequality in the where clause cannot be turned around, PL/SQL does not accept "WHERE (SELECT COUNT(*) ...) < 3"... (although I can't see the reason why)

Bye,
Lutz

-- 
Lutz Birkhahn - Unix system administrator - +49 2543 72-233
Dr. Otto Suwelack Nachf. GmbH & Co, D-48727 Billerbeck
Received on Mon Jun 23 1997 - 00:00:00 CEST

Original text of this message