<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Find Nth Highest Salary of Employee &#8211; Query to Retrieve the Nth Maximum value</title>
	<atom:link href="http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: amol</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-57537</link>
		<dc:creator>amol</dc:creator>
		<pubDate>Thu, 12 Nov 2009 05:03:27 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-57537</guid>
		<description>This query has good execution plan among all the queries explained here .

Select * 
from (Select *, DENSE_RANK() OVER (ORDER BY Salary DESC) AS Ranks from #T1) a
WHERE Ranks = N

Thanks,
-Amol.</description>
		<content:encoded><![CDATA[<p>This query has good execution plan among all the queries explained here .</p>
<p>Select *<br />
from (Select *, DENSE_RANK() OVER (ORDER BY Salary DESC) AS Ranks from #T1) a<br />
WHERE Ranks = N</p>
<p>Thanks,<br />
-Amol.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mohnish82</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-57500</link>
		<dc:creator>mohnish82</dc:creator>
		<pubDate>Tue, 10 Nov 2009 18:10:24 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-57500</guid>
		<description>@Mookkandi @sharad

Here&#039;s an explanation of how the following query works:

For each row, this query makes a cartesian product with other rows of the table. Then according to the inner query syntax, it compares the salaries. Then, the number comparison in the first outer query makes sure that only those records are picked which satisfy the criteria. E.g.

Let&#039;s say u got 3 records, with salaries 10, 20 and 30. So, the cartesian product is something like,
1) For row with sal 10 --&gt; 10-10, 10-20, 10-30 
2) For row with sal 20 --&gt; 20-10, 20-20, 20-30
3) For row with sal 30 --&gt; 30-10, 30-20, 30-30

Now apply the condition, e1.sal  10-10, 10-20, 10-30  (3)
2) For row with sal 20 --&gt; 20-10, 20-20, 20-30  (2)
3) For row with sal 30 --&gt; 30-10, 30-20, 30-30  (1)

Now the outer condition, 2&lt;= (the count arrived at above). So only 2) and 3) get selected. Hence, it shows salaries according to outer query for these two i.e. 20 and 30.

PS: This is inefficient and should be avoided. Prefer rank() in Oracle

Hope it helps.</description>
		<content:encoded><![CDATA[<p>@Mookkandi @sharad</p>
<p>Here&#8217;s an explanation of how the following query works:</p>
<p>For each row, this query makes a cartesian product with other rows of the table. Then according to the inner query syntax, it compares the salaries. Then, the number comparison in the first outer query makes sure that only those records are picked which satisfy the criteria. E.g.</p>
<p>Let&#8217;s say u got 3 records, with salaries 10, 20 and 30. So, the cartesian product is something like,<br />
1) For row with sal 10 &#8211;&gt; 10-10, 10-20, 10-30<br />
2) For row with sal 20 &#8211;&gt; 20-10, 20-20, 20-30<br />
3) For row with sal 30 &#8211;&gt; 30-10, 30-20, 30-30</p>
<p>Now apply the condition, e1.sal  10-10, 10-20, 10-30  (3)<br />
2) For row with sal 20 &#8211;&gt; 20-10, 20-20, 20-30  (2)<br />
3) For row with sal 30 &#8211;&gt; 30-10, 30-20, 30-30  (1)</p>
<p>Now the outer condition, 2&lt;= (the count arrived at above). So only 2) and 3) get selected. Hence, it shows salaries according to outer query for these two i.e. 20 and 30.</p>
<p>PS: This is inefficient and should be avoided. Prefer rank() in Oracle</p>
<p>Hope it helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sharad</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-57329</link>
		<dc:creator>sharad</dc:creator>
		<pubDate>Wed, 04 Nov 2009 14:46:07 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-57329</guid>
		<description>select max(e1.sal), e1.deptno from emp e1

where 2&lt;=(select count(*) from
emp e2 where e1.sal &lt;= e2.sal)

group by deptno;


can u explain this query how its work



explain  where condiation also ????</description>
		<content:encoded><![CDATA[<p>select max(e1.sal), e1.deptno from emp e1</p>
<p>where 2&lt;=(select count(*) from<br />
emp e2 where e1.sal &lt;= e2.sal)</p>
<p>group by deptno;</p>
<p>can u explain this query how its work</p>
<p>explain  where condiation also ????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ninja</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-57284</link>
		<dc:creator>ninja</dc:creator>
		<pubDate>Tue, 03 Nov 2009 06:10:58 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-57284</guid>
		<description>@debadutta..

u can work on this…

select max(e1.sal), e1.deptno from emp e1

where 2&lt;=(select count(*) from
emp e2 where e1.sal &lt;= e2.sal)

group by deptno;

u might get ur solution….i supose…just work on this</description>
		<content:encoded><![CDATA[<p>@debadutta..</p>
<p>u can work on this…</p>
<p>select max(e1.sal), e1.deptno from emp e1</p>
<p>where 2&lt;=(select count(*) from<br />
emp e2 where e1.sal &lt;= e2.sal)</p>
<p>group by deptno;</p>
<p>u might get ur solution….i supose…just work on this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ninja</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-57283</link>
		<dc:creator>ninja</dc:creator>
		<pubDate>Tue, 03 Nov 2009 06:10:27 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-57283</guid>
		<description>@debadutta..

u can work on this...

select max(e1.sal), e1.deptno from emp e1 

where 2&lt;=(select count(*) from
emp e2 where e1.sal &lt;= e2.sal)

group by deptno;




u might get ur solution....i supose...just work on this</description>
		<content:encoded><![CDATA[<p>@debadutta..</p>
<p>u can work on this&#8230;</p>
<p>select max(e1.sal), e1.deptno from emp e1 </p>
<p>where 2&lt;=(select count(*) from<br />
emp e2 where e1.sal &lt;= e2.sal)</p>
<p>group by deptno;</p>
<p>u might get ur solution&#8230;.i supose&#8230;just work on this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ninja</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-57282</link>
		<dc:creator>ninja</dc:creator>
		<pubDate>Tue, 03 Nov 2009 06:05:57 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-57282</guid>
		<description>superb...

thankx..

very goood.</description>
		<content:encoded><![CDATA[<p>superb&#8230;</p>
<p>thankx..</p>
<p>very goood.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pramod</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-57264</link>
		<dc:creator>pramod</dc:creator>
		<pubDate>Mon, 02 Nov 2009 10:00:06 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-57264</guid>
		<description>Thanks 
so good  answer</description>
		<content:encoded><![CDATA[<p>Thanks<br />
so good  answer</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: debadutta</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-57173</link>
		<dc:creator>debadutta</dc:creator>
		<pubDate>Fri, 30 Oct 2009 09:57:28 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-57173</guid>
		<description>Hi, Pinal.
It is a great article on finding the nth highest value in a column.
I have a dummy table emp(emp_name,deptname,salary)
and i want to find out the second highest salary department wise.

would you please help me to sort it out ?
anyone&#039;s help will be greatly appreciated..

Thanks and regards
Deba</description>
		<content:encoded><![CDATA[<p>Hi, Pinal.<br />
It is a great article on finding the nth highest value in a column.<br />
I have a dummy table emp(emp_name,deptname,salary)<br />
and i want to find out the second highest salary department wise.</p>
<p>would you please help me to sort it out ?<br />
anyone&#8217;s help will be greatly appreciated..</p>
<p>Thanks and regards<br />
Deba</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anshu</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-57134</link>
		<dc:creator>Anshu</dc:creator>
		<pubDate>Thu, 29 Oct 2009 09:21:37 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-57134</guid>
		<description>Please explain the following query as in how it is interperated.
SELECT    *
FROM    emp A
WHERE    (n-1) = (
SELECT COUNT(DISTINCT(B.salary))
FROM emp B
WHERE B.salary &gt; A.salary)</description>
		<content:encoded><![CDATA[<p>Please explain the following query as in how it is interperated.<br />
SELECT    *<br />
FROM    emp A<br />
WHERE    (n-1) = (<br />
SELECT COUNT(DISTINCT(B.salary))<br />
FROM emp B<br />
WHERE B.salary &gt; A.salary)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-56821</link>
		<dc:creator>Brian Tkatch</dc:creator>
		<pubDate>Tue, 20 Oct 2009 18:07:19 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-56821</guid>
		<description>The way to find nth ranking, is with RANK().

SELECT sal FROM 
(SELECT sal, RANK(ORDER BY sal DESC) rn)
WHERE rn = rank-you-want

This will report all people at that level. If, however, you want one and only one, ROW_NUMBER():

SELECT sal FROM 
(SELECT sal, ROW_NUMBER() OVER(ORDER BY sal DESC) rn)
WHERE rn = rank-you-want</description>
		<content:encoded><![CDATA[<p>The way to find nth ranking, is with RANK().</p>
<p>SELECT sal FROM<br />
(SELECT sal, RANK(ORDER BY sal DESC) rn)<br />
WHERE rn = rank-you-want</p>
<p>This will report all people at that level. If, however, you want one and only one, ROW_NUMBER():</p>
<p>SELECT sal FROM<br />
(SELECT sal, ROW_NUMBER() OVER(ORDER BY sal DESC) rn)<br />
WHERE rn = rank-you-want</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sharad</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-56817</link>
		<dc:creator>sharad</dc:creator>
		<pubDate>Tue, 20 Oct 2009 14:34:31 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-56817</guid>
		<description>i want to retrive nth  max sal from emp..........this query gvn eroor please solve it and tell me






SQL&gt; SELECT TOP 1 sal
  2  FROM (
  3  SELECT DISTINCT TOP 6 sal
  4  FROM emp
  5  ORDER BY sal DESC) a
  6  ORDER BY sal;
SELECT TOP 1 sal
           *
ERROR at line 1:
ORA-00923: FROM keyword not found where expected


SQL&gt; SELECT  sal
  2  FROM (
  3  SELECT DISTINCT TOP 6 sal
  4  FROM emp
  5  ORDER BY sal DESC) a
  6  ORDER BY sal;
SELECT DISTINCT TOP 6 sal
                    *
ERROR at line 3:
ORA-00923: FROM keyword not found where expected</description>
		<content:encoded><![CDATA[<p>i want to retrive nth  max sal from emp&#8230;&#8230;&#8230;.this query gvn eroor please solve it and tell me</p>
<p>SQL&gt; SELECT TOP 1 sal<br />
  2  FROM (<br />
  3  SELECT DISTINCT TOP 6 sal<br />
  4  FROM emp<br />
  5  ORDER BY sal DESC) a<br />
  6  ORDER BY sal;<br />
SELECT TOP 1 sal<br />
           *<br />
ERROR at line 1:<br />
ORA-00923: FROM keyword not found where expected</p>
<p>SQL&gt; SELECT  sal<br />
  2  FROM (<br />
  3  SELECT DISTINCT TOP 6 sal<br />
  4  FROM emp<br />
  5  ORDER BY sal DESC) a<br />
  6  ORDER BY sal;<br />
SELECT DISTINCT TOP 6 sal<br />
                    *<br />
ERROR at line 3:<br />
ORA-00923: FROM keyword not found where expected</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raj</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-56652</link>
		<dc:creator>Raj</dc:creator>
		<pubDate>Tue, 13 Oct 2009 10:03:47 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-56652</guid>
		<description>@ All
 
Thanks guys ... for valuable posts ... keep posting ...  its a good sign for us ... we can share and solve others problems too....



regards,

Raj</description>
		<content:encoded><![CDATA[<p>@ All</p>
<p>Thanks guys &#8230; for valuable posts &#8230; keep posting &#8230;  its a good sign for us &#8230; we can share and solve others problems too&#8230;.</p>
<p>regards,</p>
<p>Raj</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raj</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-56651</link>
		<dc:creator>Raj</dc:creator>
		<pubDate>Tue, 13 Oct 2009 09:48:53 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-56651</guid>
		<description>@ Srinu ,

Just check this query . It will give 4th highest salary from the list of employee salaries.


SELECT        MIN(empsal) AS Empsalary
FROM            emp
WHERE        (empsal IN
                             (SELECT DISTINCT TOP (4) empsal
                               FROM  emp AS emp_1
                               ORDER BY empsal DESC))

notice that emp_1 is created while executing the query. Its automatically generated one.</description>
		<content:encoded><![CDATA[<p>@ Srinu ,</p>
<p>Just check this query . It will give 4th highest salary from the list of employee salaries.</p>
<p>SELECT        MIN(empsal) AS Empsalary<br />
FROM            emp<br />
WHERE        (empsal IN<br />
                             (SELECT DISTINCT TOP (4) empsal<br />
                               FROM  emp AS emp_1<br />
                               ORDER BY empsal DESC))</p>
<p>notice that emp_1 is created while executing the query. Its automatically generated one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raj</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-56650</link>
		<dc:creator>Raj</dc:creator>
		<pubDate>Tue, 13 Oct 2009 09:44:10 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-56650</guid>
		<description>@ Srinu

No need to confuse with the &#039; a &#039; . Its just a alias name given for the table particularly in the case of sub queries. Be aware that we written a sub query to achieve the result.

If u didn&#039;t specify the name in SQL Server 2000/2005 , it wont give any effect to the result but just observe that when u execute the query system will automatically attach table name_1 alias name to the table.

I hope u got somewhat clear idea.

Regards,

Raj</description>
		<content:encoded><![CDATA[<p>@ Srinu</p>
<p>No need to confuse with the &#8216; a &#8216; . Its just a alias name given for the table particularly in the case of sub queries. Be aware that we written a sub query to achieve the result.</p>
<p>If u didn&#8217;t specify the name in SQL Server 2000/2005 , it wont give any effect to the result but just observe that when u execute the query system will automatically attach table name_1 alias name to the table.</p>
<p>I hope u got somewhat clear idea.</p>
<p>Regards,</p>
<p>Raj</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-55996</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Sun, 20 Sep 2009 05:44:16 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-55996</guid>
		<description>@Srinu,

Which variable you are talking about, I dont see any variable.

Please post your complete question. 

~IM.</description>
		<content:encoded><![CDATA[<p>@Srinu,</p>
<p>Which variable you are talking about, I dont see any variable.</p>
<p>Please post your complete question. </p>
<p>~IM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srinu</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-55980</link>
		<dc:creator>srinu</dc:creator>
		<pubDate>Sat, 19 Sep 2009 05:55:39 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-55980</guid>
		<description>hi this is srinu,
i have visited ur site multiple times,
really ur publishing valuable information to beginners like me. 

in this query u used a 

SELECT TOP 1 Sal
FROM (
SELECT DISTINCT TOP 2 Sal
FROM Emp
ORDER BY Sal DESC) a
ORDER BY Sal

why did u use that a variable can u explain me..

thanks in advance
regards
Srinu Ganaparthi</description>
		<content:encoded><![CDATA[<p>hi this is srinu,<br />
i have visited ur site multiple times,<br />
really ur publishing valuable information to beginners like me. </p>
<p>in this query u used a </p>
<p>SELECT TOP 1 Sal<br />
FROM (<br />
SELECT DISTINCT TOP 2 Sal<br />
FROM Emp<br />
ORDER BY Sal DESC) a<br />
ORDER BY Sal</p>
<p>why did u use that a variable can u explain me..</p>
<p>thanks in advance<br />
regards<br />
Srinu Ganaparthi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: asasd</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-55913</link>
		<dc:creator>asasd</dc:creator>
		<pubDate>Wed, 16 Sep 2009 12:01:11 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-55913</guid>
		<description>&#039;,sp_tables --&#039;</description>
		<content:encoded><![CDATA[<p>&#8216;,sp_tables &#8211;&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepak</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-55005</link>
		<dc:creator>Deepak</dc:creator>
		<pubDate>Wed, 19 Aug 2009 04:39:25 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-55005</guid>
		<description>Some thing missed in the above querry. please do refer to this
1&gt; SELECT * from employee e1 WHERE 1=(SELECT COUNT(DISTINCT salary) from employee e2 WHERE e1.salary SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP 6 salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary
what u mean by TOP1 &amp; TOP6. Is it a column name in the table or to display in the out put.
please do explain me the querry.</description>
		<content:encoded><![CDATA[<p>Some thing missed in the above querry. please do refer to this<br />
1&gt; SELECT * from employee e1 WHERE 1=(SELECT COUNT(DISTINCT salary) from employee e2 WHERE e1.salary SELECT TOP 1 salary<br />
FROM (<br />
SELECT DISTINCT TOP 6 salary<br />
FROM employee<br />
ORDER BY salary DESC) a<br />
ORDER BY salary<br />
what u mean by TOP1 &amp; TOP6. Is it a column name in the table or to display in the out put.<br />
please do explain me the querry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepak</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-55004</link>
		<dc:creator>Deepak</dc:creator>
		<pubDate>Wed, 19 Aug 2009 04:36:52 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-55004</guid>
		<description>Hi friends ,

     i am new to SQl.. so could u please help me out in finding the second highest and third highest sal .
  And please explain me the query what it does.
example :

1&gt; SELECT * from employee e1 WHERE 1=(SELECT COUNT(DISTINCT salary) from employee e2 WHERE e1.salary SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP 6 salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary
 what u mean by TOP1. Is it a column name in the table or to display in the out put.
please do explain me the querry.

Thanks in advance..............

Regards,
Deepak</description>
		<content:encoded><![CDATA[<p>Hi friends ,</p>
<p>     i am new to SQl.. so could u please help me out in finding the second highest and third highest sal .<br />
  And please explain me the query what it does.<br />
example :</p>
<p>1&gt; SELECT * from employee e1 WHERE 1=(SELECT COUNT(DISTINCT salary) from employee e2 WHERE e1.salary SELECT TOP 1 salary<br />
FROM (<br />
SELECT DISTINCT TOP 6 salary<br />
FROM employee<br />
ORDER BY salary DESC) a<br />
ORDER BY salary<br />
 what u mean by TOP1. Is it a column name in the table or to display in the out put.<br />
please do explain me the querry.</p>
<p>Thanks in advance&#8230;&#8230;&#8230;&#8230;..</p>
<p>Regards,<br />
Deepak</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sam</title>
		<link>http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/#comment-53925</link>
		<dc:creator>sam</dc:creator>
		<pubDate>Tue, 21 Jul 2009 16:40:16 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=556#comment-53925</guid>
		<description>thanks shah.</description>
		<content:encoded><![CDATA[<p>thanks shah.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
