Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Qery to select 2nd n 6th max salary

Author  Topic 

chinlax
Starting Member

30 Posts

Posted - 2011-10-17 : 00:33:45
Hi all,
I am struggling to get this
1)Write a query to get 2nd & 6th max salary from EMP table
2)Write a query to get least 3 salaries from the EMP table

i can get separately the 2n and 6th max but how to club both

and how to the least 3 salaries, i want to display all the 3 least salaries.

Emp table contains columns. empno, ename, sal, deptno

can any one help me out

Thanks in advance.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-10-17 : 00:40:32
HINT : use row_number()

http://msdn.microsoft.com/en-us/library/ms186734.aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-17 : 01:27:55
see examples usage below

http://beyondrelational.com/blogs/madhivanan/archive/2007/08/27/multipurpose-row-number-function.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -