Re: SQL question

From: Stephan Langer <slanger_at_dixi-wc.de>
Date: Thu, 02 Nov 2000 16:22:27 +0100
Message-ID: <3A0186B3.F4D89400_at_dixi-wc.de>


select * from (select dept, name, salary from "table" order by salary desc) where rownum < 4 and department = one_you_want;

but, that will only work in Oracle 8i (8.1.5 and later), not 7 (sure) and
not in 8.0 (not so sure, just try).
It's because in 8i you can use order by in subqueries, in Oracle 7 you can't.

hth
SL

xdba_at_my-deja.com schrieb:

> Given an employees table like this,
> how could I query the top three salaried people per department inSQL?
>
> Dept Name Salary
> 1 Smith 1000
> 1 Jones 2000
> 1 White 1000
> 1 Black 3000
> 1 Red 1000
> 1 Blue 1000
> 1 Smith 5000
> 2 Apple 1000
> 2 Pear 3000
> 2 Peach 1000
> 2 Lemon 4000
> 2 Melon 2000
> 2 Peach 3000
> 2 Prune 1000
> etc.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Thu Nov 02 2000 - 16:22:27 CET

Original text of this message