I used MAX function.
How to get the second highest maths mark from the database.
e.g: (maths : 96 , 88 , 55);
SELECT MAX(maths) FROM mark;
how do I get 88 from SQL query?
I used MAX function.
How to get the second highest maths mark from the database.
e.g: (maths : 96 , 88 , 55);
SELECT MAX(maths) FROM mark;
how do I get 88 from SQL query?
If you want the second highest mark, you would use limit
/offset
:
SELECT DISTINCT maths
FROM mark
ORDER BY maths DESC
LIMIT 1, 1;
You could use a subquery to get the overall maximum and then get the maximum of those values less the overall maximum.
SELECT max(maths)
FROM mark
WHERE math < (SELECT max(maths)
FROM mark);
SELECT MAX( maths ) FROM mark WHERE maths < ( SELECT MAX( maths ) FROM mark )
Try this query
SELECT MAX(maths) FROM mark WHERE maths NOT IN ( SELECT Max(maths) FROM mark);
The below code will help you.
SELECT DISTINCT mark
FROM testing
ORDER BY mark DESC
LIMIT 1, 1
And I just attached my table screen for your reference.