.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

Write a query to Select top 2 Highest salaries?

Posted By :Mallikarjuna Chigicherla     Posted Date :August 14, 2010    Points :10   Category :Sql Server 
select Top(2) salary from Tablename order by Salary desc....

You can also find related Interview Question to Write a query to Select top 2 Highest salaries?  below: 

Write Query to get nth Highest Salary in SQL Server

  
Select TOP 1 Salary as
from (SELECT DISTINCT TOP nth Salary from Employee ORDER BY Salary DESC)
a ORDER BY Salary ASC (More...)

Write and justify output of - select nullif('test','test')

  
The output will be - NULL
Justification : nullif returns NULl if given two arguments are same else returns the first specified argument. So, for the given SQL, output will be NULL. (More...)

Findout Top 2 Highest Salary By Using sql query?

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

Why NoLock is used in Sql Select Query?

  
Advantage:
applying nolock in select statement will increase
concurreny and performance in fetching.

Disadvantage:
it does'nt consider the transaction scenario, even if the
transaction is under process not yet commited or rollback
it will fetch the current record
eg

begin tran
insert into tablename
values('1','asdf')

select * from tablename with (nolock)

-- it will display the table with inserted record.
but the transaction is not completed, it can be rollback
so it became dirty read.

(More...)

Write a query to get the second maximum salary using Sql Server 2005 function?

  

SELECT Salary
FROM (
SELECT Salary, RANK() OVER (ORDER BY Salary DESC) AS MaxSalary
FROM dbo.Employee
) a
WHERE MaxSalary = 2
(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...)

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

  
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
(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...)

Write Query to get nth Lowest Salary in SQL Server

  
Select TOP 1 Salary as
from (SELECT DISTINCT TOP n Salary from Employee ORDER BY Salary ASC)
a ORDER BY Salary DESC (More...)

What is Query evaluation engine?

  
It executes low-level instruction generated by compiler. (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