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

Answer Posted / dinesh gupta

4th highest salary

SELECT * FROM(
SELECT ROW_NUMBER() OVER (ORDER BY
grosssalary desc) AS salaryno , *
FROM (
select distinct grosssalary
from salarydetails where inmon='dec' and inyear = 2007
) as a
) As T
WHERE t.salaryno = 4

3rd lowest salary

SELECT * FROM(
SELECT ROW_NUMBER() OVER (ORDER BY
grosssalary ) AS salaryno , *
FROM (
select distinct grosssalary
from salarydetails where inmon='dec' and inyear = 2007
) as a
) As T
WHERE t.salaryno = 3

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is foreign key unique?

664


Which are the two editions in which SQL Azure database available?

109


What is report snapshot in ssrs?

190


what is a self join? : Sql server database administration

615


What is the difference between rank and dense_rank?

591






How to list all field names in the result set using mssql_field_name()?

613


What are the advantages of using stored procedures?

604


Can foreign key be duplicate?

735


What do mean by xml datatype?

701


What is the Control Flow in SSIS

650


What protocol does sql server use?

602


Can you explain what are commit and rollback in sql?

579


Can you name a few encryption mechanisms in sql server?

603


Explain the characteristics of a transaction server for example atomicity, consistency, isolation, durability?

604


What is dirty page?

644