<?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; Multiple CTE in One SELECT Statement Query</title>
	<atom:link href="http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Sun, 12 Feb 2012 09:22:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: leplep29</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-250798</link>
		<dc:creator><![CDATA[leplep29]]></dc:creator>
		<pubDate>Fri, 10 Feb 2012 04:27:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-250798</guid>
		<description><![CDATA[can you help me with this kind of query

category table
having categoryID,categoryName,parentCategory,categoryStatus

i want to have just like this output

categoryID &#124; CategoryName &#124; ParentCategory &#124; CategoryStatus
1                     Shoes                   null                           Active
2                     Shoes&gt;Air             1                            Active
3                 Shoes&gt;Air&gt;Jordan     2                            Active

Hope you might help thanks ;)]]></description>
		<content:encoded><![CDATA[<p>can you help me with this kind of query</p>
<p>category table<br />
having categoryID,categoryName,parentCategory,categoryStatus</p>
<p>i want to have just like this output</p>
<p>categoryID | CategoryName | ParentCategory | CategoryStatus<br />
1                     Shoes                   null                           Active<br />
2                     Shoes&gt;Air             1                            Active<br />
3                 Shoes&gt;Air&gt;Jordan     2                            Active</p>
<p>Hope you might help thanks ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Convert Subquery to CTE &#8211; SQL in Sixty Seconds #001 &#8211; Video &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-249749</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Convert Subquery to CTE &#8211; SQL in Sixty Seconds #001 &#8211; Video &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Wed, 08 Feb 2012 01:32:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-249749</guid>
		<description><![CDATA[[...] on CTE: Simple Example of Recursive CTE Multiple CTE in One SELECT Statement Query Common Table Expression (CTE) and Few Observation Delete Duplicate Rows Simple Example of Recursive [...]]]></description>
		<content:encoded><![CDATA[<p>[...] on CTE: Simple Example of Recursive CTE Multiple CTE in One SELECT Statement Query Common Table Expression (CTE) and Few Observation Delete Duplicate Rows Simple Example of Recursive [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Common Gotcha&#8217;s Associated with Common Table Expressions (CTE) &#8211; Quiz &#8211; Puzzle &#8211; 26 of 31 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-244326</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Common Gotcha&#8217;s Associated with Common Table Expressions (CTE) &#8211; Quiz &#8211; Puzzle &#8211; 26 of 31 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Fri, 27 Jan 2012 01:31:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-244326</guid>
		<description><![CDATA[[...] and Answers ISBN: 1466405643 Page#109-112 Common Table Expression (CTE) and Few Observation Multiple CTE in One SELECT Statement Query Delete Duplicate Rows Simple Example of Recursive CTE SQL SERVER – Simple Example of Recursive [...]]]></description>
		<content:encoded><![CDATA[<p>[...] and Answers ISBN: 1466405643 Page#109-112 Common Table Expression (CTE) and Few Observation Multiple CTE in One SELECT Statement Query Delete Duplicate Rows Simple Example of Recursive CTE SQL SERVER – Simple Example of Recursive [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sairam</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-234773</link>
		<dc:creator><![CDATA[sairam]]></dc:creator>
		<pubDate>Tue, 10 Jan 2012 11:44:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-234773</guid>
		<description><![CDATA[Hi i need clarification for this.my req. is this how should i do 
With CTE1 AS
(
)
,CTE2 AS
(
)
If(@inputId = 0)
SELECT * from CTE1
else
SELECT * from CTE2]]></description>
		<content:encoded><![CDATA[<p>Hi i need clarification for this.my req. is this how should i do<br />
With CTE1 AS<br />
(<br />
)<br />
,CTE2 AS<br />
(<br />
)<br />
If(@inputId = 0)<br />
SELECT * from CTE1<br />
else<br />
SELECT * from CTE2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Kennedy</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-184697</link>
		<dc:creator><![CDATA[Eric Kennedy]]></dc:creator>
		<pubDate>Fri, 28 Oct 2011 19:46:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-184697</guid>
		<description><![CDATA[Still a useful article 2 years later.   I have to say, I like the elegance of method 1, but after many rounds of performance testing, I found method 2 to run faster.

Thanks for the article.  It solved my problem]]></description>
		<content:encoded><![CDATA[<p>Still a useful article 2 years later.   I have to say, I like the elegance of method 1, but after many rounds of performance testing, I found method 2 to run faster.</p>
<p>Thanks for the article.  It solved my problem</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dok</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-141633</link>
		<dc:creator><![CDATA[Dok]]></dc:creator>
		<pubDate>Fri, 17 Jun 2011 13:02:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-141633</guid>
		<description><![CDATA[Id &#124; Column1 &#124; Column2 &#124; Column3
1 &#124; 5 &#124; 5 =&gt; Same as Column1 &#124; 5 =&gt; Same as Column2
2 &#124; 2 &#124; 12 =&gt; 2+5+5 &#124; 17 =&gt; 12+5
3 &#124; 3 &#124; 32 =&gt; 3+12+17 &#124; 49 =&gt; 32+17]]></description>
		<content:encoded><![CDATA[<p>Id | Column1 | Column2 | Column3<br />
1 | 5 | 5 =&gt; Same as Column1 | 5 =&gt; Same as Column2<br />
2 | 2 | 12 =&gt; 2+5+5 | 17 =&gt; 12+5<br />
3 | 3 | 32 =&gt; 3+12+17 | 49 =&gt; 32+17</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dok</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-141632</link>
		<dc:creator><![CDATA[Dok]]></dc:creator>
		<pubDate>Fri, 17 Jun 2011 13:00:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-141632</guid>
		<description><![CDATA[Now I want to solve one problem again. 

I want to make columns in a table like below: 

Id   Column1    Column2                                                                                                        Column3
1    5                   5 =&gt; Same as Column1                                                                                5 =&gt; Same as Column2
2    2                  12 =&gt; column1 current + column2.prev + column3.previous = 2+5+5  17 =&gt; column2.current + column3.prev = 12+5
3    3                32 =&gt; 3+12+17      

easier way to see:

Id   Column1    Column2                       Column3
1    5          5 =&gt; Same as Column1     5 =&gt; Same as Column2
2    2          12 =&gt;   2+5+5                        17 =&gt; 12+5
3    3          32 =&gt;   3+12+17                    49 =&gt; 32+17

I am looking forward any answer and it will be appreciated. Thank you in advance

Dok]]></description>
		<content:encoded><![CDATA[<p>Now I want to solve one problem again. </p>
<p>I want to make columns in a table like below: </p>
<p>Id   Column1    Column2                                                                                                        Column3<br />
1    5                   5 =&gt; Same as Column1                                                                                5 =&gt; Same as Column2<br />
2    2                  12 =&gt; column1 current + column2.prev + column3.previous = 2+5+5  17 =&gt; column2.current + column3.prev = 12+5<br />
3    3                32 =&gt; 3+12+17      </p>
<p>easier way to see:</p>
<p>Id   Column1    Column2                       Column3<br />
1    5          5 =&gt; Same as Column1     5 =&gt; Same as Column2<br />
2    2          12 =&gt;   2+5+5                        17 =&gt; 12+5<br />
3    3          32 =&gt;   3+12+17                    49 =&gt; 32+17</p>
<p>I am looking forward any answer and it will be appreciated. Thank you in advance</p>
<p>Dok</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dok</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-141624</link>
		<dc:creator><![CDATA[Dok]]></dc:creator>
		<pubDate>Fri, 17 Jun 2011 11:53:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-141624</guid>
		<description><![CDATA[thank you, this post helped me to solve one problem. I am happy
Good luck 

Dok]]></description>
		<content:encoded><![CDATA[<p>thank you, this post helped me to solve one problem. I am happy<br />
Good luck </p>
<p>Dok</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: P Sri Sagar</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-138379</link>
		<dc:creator><![CDATA[P Sri Sagar]]></dc:creator>
		<pubDate>Thu, 02 Jun 2011 10:05:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-138379</guid>
		<description><![CDATA[Hi,

I have small doubt. The results from the above query and for the below query were same.

Then why i have to use CTE. Can you explain? Actually, i am the beginner for CTE&#039;s.


select ProductMaster.Product_ID,
ProductMaster.ProductName,
Genre.GenreName,
ProductMaster.Price
 from ProductMaster PM
Inner Join Product_Genre P_G on PM.Product_Id = P_G.Productid
Inner Join Genre G On G.Genre_Id = P_G.Genre_Id


Waiting for your reply,

Thanks &amp; Regards
Sri Sagar. P]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I have small doubt. The results from the above query and for the below query were same.</p>
<p>Then why i have to use CTE. Can you explain? Actually, i am the beginner for CTE&#8217;s.</p>
<p>select ProductMaster.Product_ID,<br />
ProductMaster.ProductName,<br />
Genre.GenreName,<br />
ProductMaster.Price<br />
 from ProductMaster PM<br />
Inner Join Product_Genre P_G on PM.Product_Id = P_G.Productid<br />
Inner Join Genre G On G.Genre_Id = P_G.Genre_Id</p>
<p>Waiting for your reply,</p>
<p>Thanks &amp; Regards<br />
Sri Sagar. P</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER – Common Table Expression (CTE) and Few Observation Journey to SQLAuthority</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-133695</link>
		<dc:creator><![CDATA[SQL SERVER – Common Table Expression (CTE) and Few Observation Journey to SQLAuthority]]></dc:creator>
		<pubDate>Tue, 10 May 2011 02:17:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-133695</guid>
		<description><![CDATA[[...] SQL Server – Multiple CTE in One SELECT Statement Query [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL Server – Multiple CTE in One SELECT Statement Query [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anand</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-129435</link>
		<dc:creator><![CDATA[Anand]]></dc:creator>
		<pubDate>Mon, 18 Apr 2011 03:34:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-129435</guid>
		<description><![CDATA[Hi Pinal,

Is there any level for recursive CTE? How many levels we can go?

Please reply.

Thanks
Anand]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>Is there any level for recursive CTE? How many levels we can go?</p>
<p>Please reply.</p>
<p>Thanks<br />
Anand</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-118645</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 15 Feb 2011 15:44:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-118645</guid>
		<description><![CDATA[Search for Delete duplicates in this site]]></description>
		<content:encoded><![CDATA[<p>Search for Delete duplicates in this site</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brijesh Bellur</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-117824</link>
		<dc:creator><![CDATA[Brijesh Bellur]]></dc:creator>
		<pubDate>Thu, 10 Feb 2011 04:01:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-117824</guid>
		<description><![CDATA[i want to remove duplicate and info is linked in different table.

for eg. if customer name, add store in one table then same customer phone no. in phone table.
so if customer name,add and phone no. are twise delete the record.



thanx madhivanan for the support

waiting for result]]></description>
		<content:encoded><![CDATA[<p>i want to remove duplicate and info is linked in different table.</p>
<p>for eg. if customer name, add store in one table then same customer phone no. in phone table.<br />
so if customer name,add and phone no. are twise delete the record.</p>
<p>thanx madhivanan for the support</p>
<p>waiting for result</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-117685</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 09 Feb 2011 13:45:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-117685</guid>
		<description><![CDATA[Which table do you want to delete data?]]></description>
		<content:encoded><![CDATA[<p>Which table do you want to delete data?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-117684</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 09 Feb 2011 13:43:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-117684</guid>
		<description><![CDATA[You cannot delete a CTE which is formed using more than one table]]></description>
		<content:encoded><![CDATA[<p>You cannot delete a CTE which is formed using more than one table</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brijesh Bellur</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-117661</link>
		<dc:creator><![CDATA[Brijesh Bellur]]></dc:creator>
		<pubDate>Wed, 09 Feb 2011 11:40:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-117661</guid>
		<description><![CDATA[table1(t1_id,t1_name)
table2(t1_id,t2_name)
table3(t1_id,t3_name)

WITH dup(t1_name,t2_name,t3_name,duplicount)
AS(SELECT t1.t1_name,t2.t2_name,t3.t3_name
ROW_NUM() OVER(PARTITION_BY t1.t1_name,t2.t2_name,t3.t3_name ORDER BY t1.t1_name)AS duplicount from table1 t1
inner join table2 t2
on t1.t1_id=t2.t1_id
inner join table3 t3
on t1.t1_id=t3.t1_id)
delete from dup

above is the example plz reply as soon as posible]]></description>
		<content:encoded><![CDATA[<p>table1(t1_id,t1_name)<br />
table2(t1_id,t2_name)<br />
table3(t1_id,t3_name)</p>
<p>WITH dup(t1_name,t2_name,t3_name,duplicount)<br />
AS(SELECT t1.t1_name,t2.t2_name,t3.t3_name<br />
ROW_NUM() OVER(PARTITION_BY t1.t1_name,t2.t2_name,t3.t3_name ORDER BY t1.t1_name)AS duplicount from table1 t1<br />
inner join table2 t2<br />
on t1.t1_id=t2.t1_id<br />
inner join table3 t3<br />
on t1.t1_id=t3.t1_id)<br />
delete from dup</p>
<p>above is the example plz reply as soon as posible</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-117580</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 09 Feb 2011 09:37:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-117580</guid>
		<description><![CDATA[Can you post the code you used?]]></description>
		<content:encoded><![CDATA[<p>Can you post the code you used?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brijesh Bellur</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-117498</link>
		<dc:creator><![CDATA[Brijesh Bellur]]></dc:creator>
		<pubDate>Wed, 09 Feb 2011 05:00:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-117498</guid>
		<description><![CDATA[hi pinal...
today i faced new challenge, i was using CTE to remove duplicate from one table but now i have to join table then i have to remove duplicate.
 but im geting this error:
&#039;&#039;View or function &#039;dup&#039; is not updatable because the modification affects multiple base tables&#039;&#039;

plz replay]]></description>
		<content:encoded><![CDATA[<p>hi pinal&#8230;<br />
today i faced new challenge, i was using CTE to remove duplicate from one table but now i have to join table then i have to remove duplicate.<br />
 but im geting this error:<br />
&#8221;View or function &#8216;dup&#8217; is not updatable because the modification affects multiple base tables&#8221;</p>
<p>plz replay</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mcarvajal</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-113912</link>
		<dc:creator><![CDATA[mcarvajal]]></dc:creator>
		<pubDate>Mon, 24 Jan 2011 22:04:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-113912</guid>
		<description><![CDATA[Gracias eso es lo que estaba buscando.]]></description>
		<content:encoded><![CDATA[<p>Gracias eso es lo que estaba buscando.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-104138</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 07 Dec 2010 11:36:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-104138</guid>
		<description><![CDATA[You need to post the sample data with the logic]]></description>
		<content:encoded><![CDATA[<p>You need to post the sample data with the logic</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-104107</link>
		<dc:creator><![CDATA[Sam]]></dc:creator>
		<pubDate>Tue, 07 Dec 2010 05:44:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-104107</guid>
		<description><![CDATA[I have two tables tblParent and tblmembers

tblParent
---------
parentid(PK), parentname, address, age

tblMembers
----------
membername, age, sex, parentid(FK)


-------------------------------
My report should show like this:
--------------------------------

100	Edwin	QRY	50
1	Sushi	45	F
2	Craig	26	M
3	Mira  	23	F

101	John	TVM	30
1	Sara	26	F
2	Sam	3	M

____________________________________________

Thanks in advance.... :)]]></description>
		<content:encoded><![CDATA[<p>I have two tables tblParent and tblmembers</p>
<p>tblParent<br />
&#8212;&#8212;&#8212;<br />
parentid(PK), parentname, address, age</p>
<p>tblMembers<br />
&#8212;&#8212;&#8212;-<br />
membername, age, sex, parentid(FK)</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
My report should show like this:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>100	Edwin	QRY	50<br />
1	Sushi	45	F<br />
2	Craig	26	M<br />
3	Mira  	23	F</p>
<p>101	John	TVM	30<br />
1	Sara	26	F<br />
2	Sam	3	M</p>
<p>____________________________________________</p>
<p>Thanks in advance&#8230;. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL Lion</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-84362</link>
		<dc:creator><![CDATA[SQL Lion]]></dc:creator>
		<pubDate>Tue, 17 Aug 2010 06:15:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-84362</guid>
		<description><![CDATA[CTEs(Common Table Expressions) are one of the beautiful and the most powerful feature of SQL Server and are boon to SQL Server developers. These not only simplifies most of the complex operations in T-SQL but also do a lot more than one can imagine. 

h ttp://www.sqllion.com/2010/08/common-table-expressions-cte/]]></description>
		<content:encoded><![CDATA[<p>CTEs(Common Table Expressions) are one of the beautiful and the most powerful feature of SQL Server and are boon to SQL Server developers. These not only simplifies most of the complex operations in T-SQL but also do a lot more than one can imagine. </p>
<p>h ttp://www.sqllion.com/2010/08/common-table-expressions-cte/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raj</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-77306</link>
		<dc:creator><![CDATA[Raj]]></dc:creator>
		<pubDate>Tue, 22 Jun 2010 15:23:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-77306</guid>
		<description><![CDATA[Hi Brian, Tejas Shah 

Thanks for reply. i solved the issue in different way since i have 2million records.. 

with ctetbl1
as(
select affinityNumber from tbl
  group by ID having COUNT(*)&gt;1),
cteTemp
as(
select *
from tbl where AffinityNumber not in(select id from ctetbl1 where ID =&#039;2&#039;)
select * from cte temp

Thanks
Raj]]></description>
		<content:encoded><![CDATA[<p>Hi Brian, Tejas Shah </p>
<p>Thanks for reply. i solved the issue in different way since i have 2million records.. </p>
<p>with ctetbl1<br />
as(<br />
select affinityNumber from tbl<br />
  group by ID having COUNT(*)&gt;1),<br />
cteTemp<br />
as(<br />
select *<br />
from tbl where AffinityNumber not in(select id from ctetbl1 where ID =&#8217;2&#8242;)<br />
select * from cte temp</p>
<p>Thanks<br />
Raj</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tejas Shah</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-76703</link>
		<dc:creator><![CDATA[Tejas Shah]]></dc:creator>
		<pubDate>Fri, 18 Jun 2010 05:12:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-76703</guid>
		<description><![CDATA[Hi Raj,

You can use this solution, if you are using SQL 2005 and above.

I have used ROW_Number to identify if it is duplicate or not and get output as you want.

DECLARE @table TABLE(IDNO INT, Code INT)
INSERT INTO @table(IDNo, Code)
SELECT 1234, 1
UNION
SELECT 3456,1
UNION
SELECT 2345, 2
UNION
SELECT 1456, 2
UNION
SELECT 1234, 2
UNION
SELECT 2345, 1
UNION
SELECT 1456, 1
UNION
SELECT 2806, 2


;with cte as (
	SELECT	ROW_NUMBER() OVER(PARTITION BY IDNo ORDER BY Code) AS RowID,
			IDNO,
			Code
	FROM @table		
)
SELECT IDNO,
		Code
FROM cte
WHERE RowID = 1

Thanks,
Tejas
SQLYoga.com]]></description>
		<content:encoded><![CDATA[<p>Hi Raj,</p>
<p>You can use this solution, if you are using SQL 2005 and above.</p>
<p>I have used ROW_Number to identify if it is duplicate or not and get output as you want.</p>
<p>DECLARE @table TABLE(IDNO INT, Code INT)<br />
INSERT INTO @table(IDNo, Code)<br />
SELECT 1234, 1<br />
UNION<br />
SELECT 3456,1<br />
UNION<br />
SELECT 2345, 2<br />
UNION<br />
SELECT 1456, 2<br />
UNION<br />
SELECT 1234, 2<br />
UNION<br />
SELECT 2345, 1<br />
UNION<br />
SELECT 1456, 1<br />
UNION<br />
SELECT 2806, 2</p>
<p>;with cte as (<br />
	SELECT	ROW_NUMBER() OVER(PARTITION BY IDNo ORDER BY Code) AS RowID,<br />
			IDNO,<br />
			Code<br />
	FROM @table<br />
)<br />
SELECT IDNO,<br />
		Code<br />
FROM cte<br />
WHERE RowID = 1</p>
<p>Thanks,<br />
Tejas<br />
SQLYoga.com</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2009/08/08/sql-server-multiple-cte-in-one-select-statement-query/#comment-76646</link>
		<dc:creator><![CDATA[Brian Tkatch]]></dc:creator>
		<pubDate>Thu, 17 Jun 2010 11:07:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6399#comment-76646</guid>
		<description><![CDATA[@Raj

How&#039;s this?

WITH
	Data(IDNo, code)
AS
	(
	 SELECT 1234, 1 UNION ALL
	 SELECT 3456, 1 UNION ALL
	 SELECT 2345, 2 UNION ALL
	 SELECT 1456, 2 UNION ALL
	 SELECT 1234, 2 UNION ALL
	 SELECT 2345, 1 UNION ALL
	 SELECT 1456, 1 UNION ALL
	 SELECT 2806, 2
	)
SELECT
		IDNo,
		MIN(code)
FROM
		Data
GROUP BY
		IDNo;]]></description>
		<content:encoded><![CDATA[<p>@Raj</p>
<p>How&#8217;s this?</p>
<p>WITH<br />
	Data(IDNo, code)<br />
AS<br />
	(<br />
	 SELECT 1234, 1 UNION ALL<br />
	 SELECT 3456, 1 UNION ALL<br />
	 SELECT 2345, 2 UNION ALL<br />
	 SELECT 1456, 2 UNION ALL<br />
	 SELECT 1234, 2 UNION ALL<br />
	 SELECT 2345, 1 UNION ALL<br />
	 SELECT 1456, 1 UNION ALL<br />
	 SELECT 2806, 2<br />
	)<br />
SELECT<br />
		IDNo,<br />
		MIN(code)<br />
FROM<br />
		Data<br />
GROUP BY<br />
		IDNo;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

