<?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/"
	
	>
<channel>
	<title>
	Comments on: SQL Puzzle: SQL Advance Query &#8211; Partition Employee Table in Three parts	</title>
	<atom:link href="https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-partition-employee-table-in-three-parts-ntile/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-partition-employee-table-in-three-parts-ntile/</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Wed, 11 Oct 2017 07:26:21 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>
		By: Dinesh.IS		</title>
		<link>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-partition-employee-table-in-three-parts-ntile/#comment-5903</link>

		<dc:creator><![CDATA[Dinesh.IS]]></dc:creator>
		<pubDate>Wed, 11 Oct 2017 07:26:21 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6577#comment-5903</guid>

					<description><![CDATA[Declare @Cnt As Numeric(19,2),@NoOfTimes Int,@LoopTime Int,@ID As Int;
Declare @SalaryDetails Table(ID Int,EmpID Int,EmpName VarChar(500),Salary Int)
Delete From @SalaryDetails
Set @Cnt=(Select Count(*) From TBL_EMP)
Set @NoOfTimes=Ceiling(@Cnt/3)
Set @LoopTime=3 
Set @ID=1
While (@ID&#060;=@LoopTime)
Begin
		
		Insert Into @SalaryDetails
		Select @ID,* From (
		Select TOP (@NoOfTimes) * From TBL_EMP
		Where EmpID Not In(Select EmpID From @SalaryDetails)
		Order By Salary ASC ) A 
		Set @ID=@ID+1

End

Select ID,Min(Salary) As FromAmount,Max(Salary) As ToAmount,Count(EMPID) As NoOfEmp
From @SalaryDetails
Group By ID]]></description>
			<content:encoded><![CDATA[<p>Declare @Cnt As Numeric(19,2),@NoOfTimes Int,@LoopTime Int,@ID As Int;<br />
Declare @SalaryDetails Table(ID Int,EmpID Int,EmpName VarChar(500),Salary Int)<br />
Delete From @SalaryDetails<br />
Set @Cnt=(Select Count(*) From TBL_EMP)<br />
Set @NoOfTimes=Ceiling(@Cnt/3)<br />
Set @LoopTime=3<br />
Set @ID=1<br />
While (@ID&lt;=@LoopTime)<br />
Begin</p>
<p>		Insert Into @SalaryDetails<br />
		Select @ID,* From (<br />
		Select TOP (@NoOfTimes) * From TBL_EMP<br />
		Where EmpID Not In(Select EmpID From @SalaryDetails)<br />
		Order By Salary ASC ) A<br />
		Set @ID=@ID+1</p>
<p>End</p>
<p>Select ID,Min(Salary) As FromAmount,Max(Salary) As ToAmount,Count(EMPID) As NoOfEmp<br />
From @SalaryDetails<br />
Group By ID</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
