Re: SQL problem

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Sat, 27 Jun 1998 18:56:28 GMT
Message-ID: <35983f6d.5213025_at_192.86.155.100>


A copy of this was sent to lasttrap_at_qatar.net.qa (if that email address didn't require changing) On Sat, 27 Jun 1998 13:47:01 GMT, you wrote:

>I need To Find The first 3 highest salary in emp table without replication.
>EX :
>this is the table Emp (empno,ename,sal)
>Ename Sal
> a 5000
>b 7000
>c 2000
>d 5000
>e 1500
>f 1000
>m 2500
>n 5000
>I need to have This result :
>Ename Sal
>b 7000
>a 5000
>m 2500
>can any one help me please .
>
select distinct sal
from emp a
where not exists ( select null

                   from emp b
                   where b.sal >= a.sal
                   having count(distinct sal) > 3 )
/

>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Sat Jun 27 1998 - 20:56:28 CEST

Original text of this message