Count() will give the numer of non-null values in sxp.

Select salary from sal s

Where 2=(select count(8) from sal s1 where s.salary

The same co-related query cabn be used to find the nth max salary the number with the where clause should be n-1 for .

## Monday, March 10, 2008

### Find 3rd max salary

Subscribe to:
Post Comments (Atom)

## 4 comments:

I didn't get this query yet. plz justify with example.

The correct syntax is listed below:

SELECT name,sal FROM emp e1 Where n=(select Count(distinct(sal)) From emp e2

WHERE e2.sal>=e1.sal)

Here n stands for nth highest salary. CHEERS.

select top 1 sal from (select distinct top 3 sal from table order by sal desc ) a

order by sal

Post a Comment