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
How to update values in a table with update statements in ms sql server?
What is a non equi join?
Can I work with several databases simultaneously? : sql server management studio
What is the name of reporting services config file and what’s it’s used for?
what is a sub-report?
Write the queries for commands like Create Table, Delete table, Drop Table etc.
Mention the differences between having and where clause.
how you can list all the tables in a database?
Do you know what is a with(nolock)?
How to use "begin ... End" statement structures in ms sql server?
Explain different types of lock modes in sql server 2000?
What is enhanced database mirroring in sql server 2008?
List all the types of user-defined functions?
How to locate and take substrings with charindex() and substring() functions?
write an SQL query to list the employees who joined in the month of January?