<?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; Print START before group and Print END after group	</title>
	<atom:link href="https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-print-start-before-group-and-print-end-after-group/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-print-start-before-group-and-print-end-after-group/</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Tue, 07 Nov 2017 06:23:46 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>
		By: Dinesh.IS		</title>
		<link>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-print-start-before-group-and-print-end-after-group/#comment-5987</link>

		<dc:creator><![CDATA[Dinesh.IS]]></dc:creator>
		<pubDate>Tue, 07 Nov 2017 06:23:46 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6651#comment-5987</guid>

					<description><![CDATA[Declare @TableResult Table(Strs VarChar(50));

Declare @Strs VarChar(50),@Cnt As Int;
Declare Cur Cursor For Select Strs,Count(*) As NoOfCnt From TBL_Texts Group By Strs 
Open Cur
Fetch Next From Cur Into @Strs,@Cnt 
While @@Fetch_Status=0
Begin 

				Insert Into @TableResult
				Values(&#039;--START--&#039;)
				While (@Cnt&#062;=1)
				Begin
						Insert Into @TableResult
						Values(@Strs)
						Set @Cnt=@CNt-1
				End
				Insert Into @TableResult
				Values(&#039;--END--&#039;)

Fetch Next From Cur Into @Strs,@Cnt
End
Close Cur
Deallocate Cur

Select * From @TableResult]]></description>
			<content:encoded><![CDATA[<p>Declare @TableResult Table(Strs VarChar(50));</p>
<p>Declare @Strs VarChar(50),@Cnt As Int;<br />
Declare Cur Cursor For Select Strs,Count(*) As NoOfCnt From TBL_Texts Group By Strs<br />
Open Cur<br />
Fetch Next From Cur Into @Strs,@Cnt<br />
While @@Fetch_Status=0<br />
Begin </p>
<p>				Insert Into @TableResult<br />
				Values(&#8216;&#8211;START&#8211;&#8216;)<br />
				While (@Cnt&gt;=1)<br />
				Begin<br />
						Insert Into @TableResult<br />
						Values(@Strs)<br />
						Set @Cnt=@CNt-1<br />
				End<br />
				Insert Into @TableResult<br />
				Values(&#8216;&#8211;END&#8211;&#8216;)</p>
<p>Fetch Next From Cur Into @Strs,@Cnt<br />
End<br />
Close Cur<br />
Deallocate Cur</p>
<p>Select * From @TableResult</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
