SQL Sever
========
select top 1 a.* from (
select top 4 salary from table1 order by salary DESC ) a order by a.salary ASC;
Now in generic terms... Lets say for Nth salary.
select top 1 a.* from (
select top N salary from table1 order by salary DESC ) a order by a.salary ASC;
Just replace N with the number you want to find the salary. (N = 1 for first, N =2 for second, N= 3 for third.. so on..).
Oracle
======
select * from (
select tb1.*, rownum Rnum from (
select * from table1 order by salary DESC) tb1 where rownum <= 2) where Rnum >= 2;
Now to make it generic.. Lets say for Nth salary.
select * from (
select tb1.*, rownum Rnum from (
select * from table1 order by salary DESC) tb1 where rownum <= N) where Rnum >= N;
Just replace N with the number you want to find the salary. (N = 1 for first, N =2 for second, N= 3 for third.. so on..).
Most of the posts in this blog are based on real time issues and scenarios. The main goal here is to share userful information and help many people out there. These information are really used and working. Please share any information you have while reading this blog.
Showing posts with label Interview Questions. Show all posts
Showing posts with label Interview Questions. Show all posts
Wednesday, May 22, 2013
Friday, April 5, 2013
Interview Question for you to think - Puzzle - HOW DO YOU DO THAT???
You have a 5 litres and a 3 litres cup. Make use of this 5 litres and 3 litres cup to exactly get 4 litres of water. Yes, I really mean exactly 4 litres of water..... HOW DO YOU DO THAT????
You have lots of water available and throw away any amount of water, it doesn't matter. Remember, you have only these two cups available. No other cups/measuring items available..
Think and post you answer.....
You have lots of water available and throw away any amount of water, it doesn't matter. Remember, you have only these two cups available. No other cups/measuring items available..
Think and post you answer.....
Thursday, April 26, 2012
Programming Test
Given a list, array, of integers, find the index of the two consecutive numbers which have the largest sum.
For example, if the array is 1, 2, 3, 4, 5, the answer is 4, as 4+5 = 9.
Subscribe to:
Posts (Atom)