SQL query for finding the 2nd highest salary from an employee table.

This is a very simple SQL query for finding the 2nd highest salary from an employee table.

A very common question in .NET interviews. The query is pretty self explanatory.

select  top(1)[Name],Salary from Employee
where  salary  not in (select top (1) salary from employee order by salary desc) ORDER BY SALARY DES

– Change the top parameter to (nth highest salary – 1)

 

22 comments

I posted your article to my myspace profile.

Regards

Feal

Do you have any more info on this?

Like your writing! Still you can do some things to improve it.

Just try to smile for about 2-3 mins then you can get back to work

I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.

Regards
Roman

wow, nice post, I was wondering what are the best registry cleaner. and found your site by bing, learned a lot, now i have got some idea. bookmarked and also signed up your rss. keep us updated.

Interesting article. Were did you got all the information from? Anyway thank you for this great post!

What I know is, is that if you do work that you love, and the work fulfills you, the rest will come.

I don’t know if I am any smarter but I enjoyed reading your post – Thank You

Comfortabl y, the article is in reality the best on this valuable topic. I harmonise with your conclusions and will thirstily look forward to your coming updates. Simply just saying thanks will certainly not simply be enough, for the awesome clarity in your writing. I will certainly quickly grab your rss feed to stay privy of any kind of updates. Fabulous work and much success in your business dealings!

Thanks for posting this. i really had good time reading this.

Hey check out my blog too. I hope i have some interesting stuff too

Nice blog!!!!!!!!!!Really a great knowledge about different thing about interim.I refer my friend to this site for more information.They also impressed by this site.<a href="http://www.cvandinterviews.com"rel="dofollow">Interview Questions And Answers</a>

Nice site, I am adding this page as a bookmark.

thanks for your posts and blogs

Leave a reply