<?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; Common Table Expression (CTE) and Few Observation</title>
	<atom:link href="http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Himadri</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-439962</link>
		<dc:creator><![CDATA[Himadri]]></dc:creator>
		<pubDate>Tue, 19 Mar 2013 07:58:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-439962</guid>
		<description><![CDATA[Hello Pinal, 

Which is faster as per performance (If I want to use in pagination)? 
Identity column in temp table or ROW_NUMBER in CTE ?]]></description>
		<content:encoded><![CDATA[<p>Hello Pinal, </p>
<p>Which is faster as per performance (If I want to use in pagination)?<br />
Identity column in temp table or ROW_NUMBER in CTE ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Misrahi</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-415348</link>
		<dc:creator><![CDATA[Adam Misrahi]]></dc:creator>
		<pubDate>Wed, 30 Jan 2013 16:48:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-415348</guid>
		<description><![CDATA[A year and a half later but just in case it&#039;s useful: I&#039;m pretty certain a CTE could only improve performance as it amounts to little more than a way to alias a bit of code you&#039;d like to repeat. In that sense the only effect it could have on the execution plan is making clear to the engine that it has to fetch something only once, not twice and that its self contained (no possibility of inline referencing a field outside its brackets).]]></description>
		<content:encoded><![CDATA[<p>A year and a half later but just in case it&#8217;s useful: I&#8217;m pretty certain a CTE could only improve performance as it amounts to little more than a way to alias a bit of code you&#8217;d like to repeat. In that sense the only effect it could have on the execution plan is making clear to the engine that it has to fetch something only once, not twice and that its self contained (no possibility of inline referencing a field outside its brackets).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Angad Singh</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-407972</link>
		<dc:creator><![CDATA[Angad Singh]]></dc:creator>
		<pubDate>Tue, 15 Jan 2013 10:23:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-407972</guid>
		<description><![CDATA[Try this Amit, 

create table #testme(
	id int, 
	name char(2),
	value int
)

insert into #testme
select 1,&#039;a&#039;,100
union all
select 2,&#039;b&#039;,200
union all
select 3,&#039;c&#039;,300
union all
select 4,&#039;d&#039;, 400

select t.id, t.name, t.value, SUM(t1.value) AS NewValue
from #testme t
inner join #testme t1 on t.id &gt;= t1.id
group by t.id, t.name, t.value]]></description>
		<content:encoded><![CDATA[<p>Try this Amit, </p>
<p>create table #testme(<br />
	id int,<br />
	name char(2),<br />
	value int<br />
)</p>
<p>insert into #testme<br />
select 1,&#8217;a',100<br />
union all<br />
select 2,&#8217;b',200<br />
union all<br />
select 3,&#8217;c',300<br />
union all<br />
select 4,&#8217;d', 400</p>
<p>select t.id, t.name, t.value, SUM(t1.value) AS NewValue<br />
from #testme t<br />
inner join #testme t1 on t.id &gt;= t1.id<br />
group by t.id, t.name, t.value</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nisha</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-390548</link>
		<dc:creator><![CDATA[Nisha]]></dc:creator>
		<pubDate>Mon, 10 Dec 2012 07:56:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-390548</guid>
		<description><![CDATA[Hi 
Try This

CREATE TABLE #test
(
	job		varchar(100),
	dept1   int,
	dept2	int,
	dept3	int
)

INSERT INTO #test VALUES(&#039;postman&#039;, 100, 200, 300)

SELECT a.job,a.dept1,a.dept2,a.dept3,A1.[SUM] 
FROM #test a
INNER JOIN
( 
	SELECT b.dept1+b.dept2+b.dept3 AS [SUM] ,b.job
	FROM #test b
) A1 ON a.job = A1.job]]></description>
		<content:encoded><![CDATA[<p>Hi<br />
Try This</p>
<p>CREATE TABLE #test<br />
(<br />
	job		varchar(100),<br />
	dept1   int,<br />
	dept2	int,<br />
	dept3	int<br />
)</p>
<p>INSERT INTO #test VALUES(&#8216;postman&#8217;, 100, 200, 300)</p>
<p>SELECT a.job,a.dept1,a.dept2,a.dept3,A1.[SUM]<br />
FROM #test a<br />
INNER JOIN<br />
(<br />
	SELECT b.dept1+b.dept2+b.dept3 AS [SUM] ,b.job<br />
	FROM #test b<br />
) A1 ON a.job = A1.job</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Garry</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-363497</link>
		<dc:creator><![CDATA[Garry]]></dc:creator>
		<pubDate>Tue, 23 Oct 2012 23:01:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-363497</guid>
		<description><![CDATA[just repeat the column again in select query

select  MyTable.id,MyTable.name,MyTable.value,MyTable.value as newadd
from MyTable]]></description>
		<content:encoded><![CDATA[<p>just repeat the column again in select query</p>
<p>select  MyTable.id,MyTable.name,MyTable.value,MyTable.value as newadd<br />
from MyTable</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sharath</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-355083</link>
		<dc:creator><![CDATA[sharath]]></dc:creator>
		<pubDate>Tue, 02 Oct 2012 07:03:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-355083</guid>
		<description><![CDATA[hello sir, 
            my crytriea is like this 


job           dept1       dept2      dept3      sum

postman   100         200                        300



how to do this]]></description>
		<content:encoded><![CDATA[<p>hello sir,<br />
            my crytriea is like this </p>
<p>job           dept1       dept2      dept3      sum</p>
<p>postman   100         200                        300</p>
<p>how to do this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: amit</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-354826</link>
		<dc:creator><![CDATA[amit]]></dc:creator>
		<pubDate>Mon, 01 Oct 2012 09:03:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-354826</guid>
		<description><![CDATA[i have query 
i need the result like 
my table is 
id name value
1  a         100
2  b          200
3  c          300

i need the result set like

id name value  newadd
1  a         100      100
2  b          200      300
3  c          300       600

kindly let me know the query pls help me i am stuk in this]]></description>
		<content:encoded><![CDATA[<p>i have query<br />
i need the result like<br />
my table is<br />
id name value<br />
1  a         100<br />
2  b          200<br />
3  c          300</p>
<p>i need the result set like</p>
<p>id name value  newadd<br />
1  a         100      100<br />
2  b          200      300<br />
3  c          300       600</p>
<p>kindly let me know the query pls help me i am stuk in this</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/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-249750</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:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-249750</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 CTE – Part 2 – MAXRECURSION – Prevent CTE [...]]]></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 CTE – Part 2 – MAXRECURSION – Prevent CTE [...]</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/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-244324</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:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-244324</guid>
		<description><![CDATA[[...] Server Interview Questions 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 [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Server Interview Questions 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 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anil kumar gutlapalli</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-137760</link>
		<dc:creator><![CDATA[anil kumar gutlapalli]]></dc:creator>
		<pubDate>Tue, 31 May 2011 09:25:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-137760</guid>
		<description><![CDATA[Pinal,

You are the most talented person in SQL i have ever seen!!!

Thank you for such a great geek info..!]]></description>
		<content:encoded><![CDATA[<p>Pinal,</p>
<p>You are the most talented person in SQL i have ever seen!!!</p>
<p>Thank you for such a great geek info..!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob Pusateri</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-133854</link>
		<dc:creator><![CDATA[Bob Pusateri]]></dc:creator>
		<pubDate>Tue, 10 May 2011 16:33:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-133854</guid>
		<description><![CDATA[Hi Pinal,

Thank you so much for contributing to T-SQL Tuesday and for sharing the links!]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>Thank you so much for contributing to T-SQL Tuesday and for sharing the links!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramdas</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-133828</link>
		<dc:creator><![CDATA[Ramdas]]></dc:creator>
		<pubDate>Tue, 10 May 2011 13:33:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-133828</guid>
		<description><![CDATA[Nice discussion on CTE&#039;s, I have Used CTE&#039;s in certain scenarios and worked very well. I am just curious to know the Performance Hit on using CTE&#039;s in more elaborate situations like trying to build a Bill Of Material for parts.]]></description>
		<content:encoded><![CDATA[<p>Nice discussion on CTE&#8217;s, I have Used CTE&#8217;s in certain scenarios and worked very well. I am just curious to know the Performance Hit on using CTE&#8217;s in more elaborate situations like trying to build a Bill Of Material for parts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-133818</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 10 May 2011 12:50:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-133818</guid>
		<description><![CDATA[Becuase WITH is already a command used in options like backup with move, etc. So in order to differentiate, it should be preceded by a semicolon]]></description>
		<content:encoded><![CDATA[<p>Becuase WITH is already a command used in options like backup with move, etc. So in order to differentiate, it should be preceded by a semicolon</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-133817</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 10 May 2011 12:49:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-133817</guid>
		<description><![CDATA[1 Use temp table
2 Set based approach with single query]]></description>
		<content:encoded><![CDATA[<p>1 Use temp table<br />
2 Set based approach with single query</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-133813</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 10 May 2011 12:38:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-133813</guid>
		<description><![CDATA[Please note that CTE can be used in a Single SELECT block only unlike temp table or table variable]]></description>
		<content:encoded><![CDATA[<p>Please note that CTE can be used in a Single SELECT block only unlike temp table or table variable</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wilfred van Dijk</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-133793</link>
		<dc:creator><![CDATA[Wilfred van Dijk]]></dc:creator>
		<pubDate>Tue, 10 May 2011 09:47:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-133793</guid>
		<description><![CDATA[I do not agree that CTE are not a replacement of temp table or Temp variable Table. I think it should be &quot;CTE can be a replacement of temp table or temp variable table&quot;.

I&#039;ve seen and created many examples of T-SQL code where temptables are being replaced by CTE. In fact I recommend replacing a temptable by a CTE if possible.]]></description>
		<content:encoded><![CDATA[<p>I do not agree that CTE are not a replacement of temp table or Temp variable Table. I think it should be &#8220;CTE can be a replacement of temp table or temp variable table&#8221;.</p>
<p>I&#8217;ve seen and created many examples of T-SQL code where temptables are being replaced by CTE. In fact I recommend replacing a temptable by a CTE if possible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zafar</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-133774</link>
		<dc:creator><![CDATA[Zafar]]></dc:creator>
		<pubDate>Tue, 10 May 2011 06:40:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-133774</guid>
		<description><![CDATA[How we can avoid cursors ?]]></description>
		<content:encoded><![CDATA[<p>How we can avoid cursors ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yap Chee Chau</title>
		<link>http://blog.sqlauthority.com/2011/05/10/sql-server-common-table-expression-cte-and-few-observation/#comment-133746</link>
		<dc:creator><![CDATA[Yap Chee Chau]]></dc:creator>
		<pubDate>Tue, 10 May 2011 05:25:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=12853#comment-133746</guid>
		<description><![CDATA[Hi Pinal,

What is the main reason of always begin CTE with semi-comma ?]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>What is the main reason of always begin CTE with semi-comma ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
