View Single Post
  #2 (permalink)  
Old 08-29-2006, 07:22 AM
Dimitar
 
Posts: n/a
Default SQL 92 answer. Re: How to find second highest value of a column in a table? | SQL?

[sql]
select score,player from scores where score=(select max(score) from scores where score< (select max(score) from scores));
[/sql]
The above finds the second highest score in the scores table and the name of the player.
Reading from right to left:
1. The first select finds the highest score.
2. The second select find the highest from the rest.
3. The last select finds the name of the player.

Hope this helps.
Edit/Delete Message Reply With Quote