Query to find the second highest column value in a table

In this ms sql server tutorial you will learn query to find the second highest column value in a table. Let’s have a look over the query that will give you second highest column value in a table.

SELECT ColumnName FROM TableName WHERE ColumnName =
( SELECT MAX(ColumnName) FROM TableName WHERE
ColumnName<(SELECT max(ColumnName) FROM TableName))

Replace ColumnName with the Name of your table’s column and replace TableName with the name of your table.


So this is the query to find the second highest column value in a table.

0 comments: