Click here to Skip to main content
15,889,877 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to select second heighest value from a table using SQL Query

the table name is Student, the fields are
StudentID( Primarykey)
Name nvarchar(50),
address nvarchar(50),
mark nvarchar(50)
Posted

We're not here to do your homework for you. If you're struggling then ask your tutors.
 
Share this answer
 
Let relate to similar problems in real life, for example finding the second tallest students in the class, one way is:
1. Line them up from tallest to the shortest from left to right (ORDER BY[^])
2. Select the first two from the left (TOP[^]).
3. The shorter (MIN()[^]) of these two is your answer.
 
Share this answer
 
v2
The second highest mark is the highest mark when the true highest mark excluded...
SQL
SELECT MAX(mark) FROM Student WHERE mark <> (SELECT MAX(mark) FROM Student)

Think about it...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900