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



I have student marks in a student table. I need second highest mark .Then what will the query for..

Answer / pravin more

select max(mark) from student where mark <
(select max(mark)from student)

Is This Answer Correct ?    53 Yes 14 No

I have student marks in a student table. I need second highest mark .Then what will the query for..

Answer / madan

This ans. particularly when you want 2nd highest marks?
and not for nth highest marks.

SELECT MAX(mark) FROM student WHERE mark <
(SELECT MAX(mark)FROM student)

Is This Answer Correct ?    18 Yes 7 No

I have student marks in a student table. I need second highest mark .Then what will the query for..

Answer / kumaravel

try using this...
select top 1 from student where marks in (select top 2 from
student order by marks desc)

Is This Answer Correct ?    16 Yes 10 No

I have student marks in a student table. I need second highest mark .Then what will the query for..

Answer / sanjay

create table test(id int identity,marks int)
insert into test
select 20
union all
select 31
union all
select 33
union all
select 1
union all
select 3
union all
select 100
union all
select 88

select * from test


with data as
(
select marks,row_number() over(order by marks desc) as rno
from test
)
select * from data where rno = 3

Is This Answer Correct ?    4 Yes 0 No

I have student marks in a student table. I need second highest mark .Then what will the query for..

Answer / supriya

select max(marks) from student where marks not in (select
max(marks) from student)

Is This Answer Correct ?    10 Yes 7 No

I have student marks in a student table. I need second highest mark .Then what will the query for..

Answer / ravindra singh

select b.marks from (select distinct marks from student)
a,(select distinct marks from student) b
where a.marks >= b.marks
group by b.marks
having count(b.marks)=3

Is This Answer Correct ?    9 Yes 7 No

I have student marks in a student table. I need second highest mark .Then what will the query for..

Answer / naresh

select top 1 age from student where age<(select top 1 age
from student where age<(select distinct max(age) from
student ))

Is This Answer Correct ?    3 Yes 1 No

I have student marks in a student table. I need second highest mark .Then what will the query for..

Answer / rakesh

In Oracle

select marks from
(select marks from
(select marks from students order by marks desc)
where rownum<3
order by marks asc)
where rownum<2

Is This Answer Correct ?    3 Yes 1 No

I have student marks in a student table. I need second highest mark .Then what will the query for..

Answer / suman

select max(mark) from student where mark <
(select max(mark)from student)

Is This Answer Correct ?    5 Yes 3 No

I have student marks in a student table. I need second highest mark .Then what will the query for..

Answer / siva prakasam

SELECT TOP (1) stuMark
FROM Student
WHERE stuMark < (SELECT MAX(stuMark) FROM Student)
ORDER BY stuMark DESC

Is This Answer Correct ?    4 Yes 2 No

Post New Answer

More SQL Server Interview Questions

How would you choose between a clustered and a non-clustered index?

0 Answers  


write the query for taking database backup in sql

10 Answers   ABC, IBM, Logica CMG, MA,


I have a website that allows customers to browse and place orders for certain products. I have 2 tables; Customers and Orders. The Customers table holds the customer records and the Orders table holds the orders placed by the customer. Both tables are tied based on the field Cust_ID. Example of the data is shown below: Cust_ID Cust_Name Cust_ID Product Amount Order_Date 1001 John Tan 1001 P-5211 $120.00 2/13/2006 1002 Michael Wong 1001 K-1428 $88.90 1/11/2006 1003 Mary Cheong 1003 C-0923 $82.50 1/27/2006 1004 Ahmad Suffian 1003 K-1428 $88.90 2/2/2006 Write a single SQL statement that extracts all purchase records with the following criteria: 1. Customer names starting with “M” only. 2. Orders placed within the current month only. 3. Amount does not exceed $100.00 The list must be sorted by order date with the latest order showing on top.

3 Answers   Techno Solutions,


What are the restrictions that views have to follow?

0 Answers  


Insert syudents details in table.Current system date &time insert into joining time.How do insert?( in sysdate only return current system date how do add time?)

0 Answers  






What are the encryption mechanisms in sql server?

0 Answers  


What is the difference between varchar and varchar(max) datatypes?

0 Answers  


Explain syntax for viewing, dropping and disabling triggers?

0 Answers  


Explain what is analysis service repository?

0 Answers  


How to get a list of columns in a view using "sys.columns" in ms sql server?

0 Answers  


What is the difference between primary key and unique constraints?

0 Answers  


What is transactional replication?

0 Answers  


Categories