View Single Post
  #6 (permalink)  
Old December 5th, 2003, 08:06 AM
Jeff Mason Jeff Mason is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try this:
Code:
SELECT T0.Name, T0.Sal FROM yourtable T0
WHERE 3 = (SELECT COUNT(DISTINCT Sal) FROM yourtable T1
        WHERE T1.Sal>=T0.Sal)
The (correlated) subquery assigns a ranking number to each row based on the 'Sal' column. The WHERE clause finds the row with the ranking number equal to 3. Note that this deals with ties by assigning the same ranking number to each row with the same value, so you could get more than one row in the resultset.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com