SQL Queries: Query for getting Second highest number record

Query for getting Second Highest Number Record from a Table

Getting Second highest Marks from table
Two SQL commands will be used to get the second highest number from the table

1. Order by
2. Limit
First we will order the numbers in descending order by using Order By command so that we can get the highest number at the first position(first row) and second highest at the second position(second row) in the table.

Next we will use Limit command to display second highest number as Limit command is used to display some part of the records returned by a query specifying a range.

SQL Query:
FROM student
LIMIT 1,1;


messagepk said...

hey can we talk for a while ? i am QA-SQL guy frm Teradata ...

messagepk said...

Question :::::

Display the full name of all employees with either an "E" or "S" in their last name.

aftab ahmad said...

this could be solved by sub query as
select max(result)
from marks
where marks < (

select max(result)
from marks
// Here inner query will result hieghest results from table marks,and out query will give second hieghest.

ShuMaiLa said...

ok Sure messagepk ... add me on skype if u need any help


Post a Comment