Re: SQL question

From: (wrong string) ³ Jank <yankee_at_wp.pl>
Date: Thu, 2 Nov 2000 15:05:35 +0100
Message-ID: <8trsg1$ono$1_at_korweta.task.gda.pl>


[Quoted] I don't think that will work. The problem is that rownum < 4 in that function is executed BEFORE order by, so that list won't be properly ordered. Remove that AND ROWNUM <4 and it should do the trick. Rafal

>
>CREATE FUNCTION Max_Salary_3 (The_Dept IN NUMBER) IS
> The_Salary NUMBER;
>BEGIN
> SELECT
> Salary INTO The_Salary
> FROM
> (SELECT
> ROWNUM R,
> Salary
> FROM
> Employees
> WHERE
> Dept = The_Dept
> 1
> ORDER BY
> Salary DESC)
> WHERE R = 3;
>END Max_Salary_3;
>/
>
>SELECT
> Dept,
> Salary
>FROM
> Employees
>WHERE
> Salary >= Max_Salary_3 (Dept)
>ORDER BY
> Dept;
>
>Brian
>
Received on Thu Nov 02 2000 - 15:05:35 CET

Original text of this message