.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> Sql Server >> Post New Question Subscribe to Interview Questions

SQL Query to find the 4th highest Value in a Table.

Posted By :Sajid P K     Posted Date :October 18, 2010    Points :10   Category :Sql Server 
Let us assume that we have Table with Student Name and Mark. We have to Find out 4th highest mark from here?


SELECT TOP 1 Mark FROM
(SELECT TOP 4 Mark FROM Student ORDER BY Mark DESC) AS E
ORDER BY Mark ASC


You can also find related Interview Question to SQL Query to find the 4th highest Value in a Table.  below: 

How to find out Second highest salary from a table?

  
select max(salary) from emp where salary not in(select max(salary) from emp) (More...)

Findout Top 2 Highest Salary By Using sql query?

  
Select Top(2) Salary from Table name Where order By Salary Desc (More...)

How to find out 3rd Highest Salary?

  
Select Min(Salary) As Salary from Tablename where Salary In(Select
distinct top 3 salary from tablename order by salary desc) (More...)

Write a query to Select top 2 Highest salaries?

  
select Top(2) salary from Tablename order by Salary desc.... (More...)

Query to find Top 10 recors in Sql

  
Select top 10 * from emp order by empid desc (More...)

Write a SQL query to send mail, whenever a new record is inserted into a table using Sqlserver 2000.

  
Here we have to create a trigger on required table as show below.


CREATE TRIGGER SendRem
ON TableX
AFTER INSERT
AS

EXEC master..xp_sendmail
@recipients='you@you.com',
@message = 'body'
@subject = 'foo was fired.'
GO
(More...)

How to find out server name using query

  


SELECT @@SERVERNAME as Server Name


The results look like the following:

Server Name
---------------------------------
Server1 (More...)

how to find the table name in sql server database?

  
select * from INFORMATION_SCHEMA.tables where table_name like 'tblname%' (More...)

how to find column name from sql server table?

  
select * from INFORMATION_SCHEMA.Columns where column_name like 'colname%' (More...)

If you 1Lakh records of employee in a table, then how will you get the 4th highest salary from the table?

  
SELECT TOP 1 * FROM [EmpTable] WHERE [salary] NOT IN (SELECT DISTINCT TOP 3 salary FROM [temp1] ORDER BY [salary] DESC) ORDER BY salary DESC (More...)

Would the select query below fetch any records?



create table #testvm (ID int)

select * from sysobjects where name = '#testvm'

drop table #testvm

  
No..

Since temp tables are created in tempdb, and use a random name, the query will not work.

If you used a query like this, you would see your table:

select * from tempdb..sysobjects where name like '#testvm%' (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend