Re: Third largest salary

From: MUSTAFA (anonymous_at_discussions.microsoft.com)
Date: 05/11/04


Date: Tue, 11 May 2004 04:02:46 -0700

i HAVE A TEST TABLE WICH HAS ONE COLUMN CALLED id

THE DATA IN TEST TABLE FOR COLUMN ID IS AS FOLLOW

1033
2093
2323
2323
45534

I WANT 3RD LARGEST VALUE I.E 2323 USING ABOVE EXAMPLE.
I USED THE BELOW QUERY BUT IT RETURN 0 ROWS.
select *
  from test a
  where
  (select count(ID) from test b where b.ID = a.ID) = 3

WAITING FOR UR REPLY
BYE

>-----Original Message-----
> hi mustafa,
>
> try something as:
>
> select *
> from <table> a
> where
> (select count(distinct salary_column) from <table> b
where b.salary_column
>>= a.salary_column) = 3
>
> replace column name and table name in above query
>
> --
> Vishal Parkar
> vgparkar@yahoo.co.in | vgparkar@hotmail.com
>
>
> "mustafa" <mustafakh@yahoo.com> wrote in message
>news:b2ea01c43736$69aca3e0$a601280a@phx.gbl...
> > Dear Sir
> >
> > I want to retrive data that will return 3rd largest
salary
> > paid employee from employee table using sql query.
> >
> > thanks
>
>
>.
>



Relevant Pages