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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a coalesce function?

661


Explain encryption of entire databases without the need for application changes in sql server 2008?

558


What is acid mean in sql server?

569


What is meant by indexing files?

574


Explain different types of collation sensitivity?

529






What are the default system databases in sql server 2000?

536


Why do we use non clustered index?

551


What is a primary index?

520


Why we should not use triggers?

534


What is sql injection? How to protect against sql injection attack?

552


How to select some specific columns from a table in a query in ms sql server?

500


Can you name some of the dml commands in sql?

548


Describe how to use the linked server?

594


What do mean by xml datatype?

611


What is page in sql server?

513