Google News
logo
Database Testing - Interview Questions
How to write a query to get the second largest value from a given column of a table?
This is a query to get the second largest value from a given column of a table.
SELECT MAX(COLUMN_NAME) FROM TABLE_NAME
WHERE COLUMN_NAME <
(SELECT MAX(COLUMN_NAME) FROM TABLE_NAME);
 
For Example : To get the second-largest marks from “Marks” column of a “Students” table.
SELECT Max(Marks) from Students
WHERE Marks< (SELECT Max(Marks) from students);
Advertisement