For Answers, see/post comments

How to select second max from Database Table in SQL Server

SELECT * FROM Student_infowhere S_id=(select max(S_id)from Student_info where S_id<(select max(S_id)from Student_info))

1 comment:

Anonymous said...

Here Table name is Detail and having one column 'age'
Query to find the second highest age is as below

select age from detail where 1=(select count(distinct(age)) from detail a where a.age > detail.age )