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
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:
SELECT *
FROM student
ORDER BY marks DESC
LIMIT 1,1;
hey can we talk for a while ? i am QA-SQL guy frm Teradata ...
ReplyDeleteQuestion :::::
ReplyDeleteDisplay the full name of all employees with either an "E" or "S" in their last name.
this could be solved by sub query as
ReplyDeleteselect 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.
ok Sure messagepk ... add me on skype if u need any help
ReplyDeleteshumaila_afzal
Great insights, this is a very informative blog! The explanation of SQL queries for finding the second-highest number is clear and useful for understanding database concepts. Similarly, choosing a professional hair treatment salon can help people find suitable solutions for dry, damaged and difficult-to-manage hair.
ReplyDeleteRead more: hair treatment salon