I have student marks in a student table. I need second
highest mark .Then what will the query for this?
Answers were Sorted based on User's Feedback
Answer / vk
select studentid,student_name,marks from
(select row_number() over (partition by marks order by marks desc) as rnk,studentid,student_name,marks from student_marks)
where studentid in (1,4);
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / lokeshwaran s
SELECT MAX(marks) AS second_highest_mark
FROM student
WHERE marks < (SELECT MAX(marks) FROM student);
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / koti,khammam
select max(mark) from student where mark not in (select max
(mark) from student)
| Is This Answer Correct ? | 1 Yes | 2 No |
Answer / poomanibe
with temptab as
(
select row_number() over(order by substring(marks,1,2)) as
rownum,* from Student
)
select * from temptab where rownum=1
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / dharmendra k. dixit
SELECT TOP 1 Marks (SELECT TOP 2 Marks from Tablename Order
by Marks Desc)From Tablename order by Marks Asc
| Is This Answer Correct ? | 0 Yes | 2 No |
Answer / rupa
Select max(Marks) from Marks where Marks <
(select max(Marks)from Marks)
| Is This Answer Correct ? | 0 Yes | 2 No |
Answer / sagesh
SELECT * FROM(
SELECT ROW_NUMBER() OVER (ORDER BY mark) AS Stu_Rank
FROM student) As T
WHERE Stu_Rank = 2
| Is This Answer Correct ? | 2 Yes | 5 No |
Write a Select Query to display title for each group of records, which are collected with Compute Clause? Like titlefield column-A column-B ..... ..... ..... Sum ... titlefield column-A column-B ..... ..... ..... Sum ...
How should i optimize the time for execution of stored procedure having single input and many output from the different tables?
How to set database to be read_only in ms sql server?
Explain collation?
What are trace files?
Can we call a function that has out parameter in select statement
What is abstracting periodical?
How to move database physical files in ms sql server?
How to execute a sql statement using mssql_query()?
select the 3rd maximum salary from sql server database if 4 (just an example In practically I may not know the exact situation) of the highest salaries are equal.
What is a trigger in sql server?
What is the purpose of indexing?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)