<?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; PIVOT and UNPIVOT Table Examples</title>
	<atom:link href="http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Thu, 09 Feb 2012 10:40:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Jai Kumar</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-250341</link>
		<dc:creator><![CDATA[Jai Kumar]]></dc:creator>
		<pubDate>Thu, 09 Feb 2012 06:46:56 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-250341</guid>
		<description><![CDATA[Good site..
My query is...

i have 3 columns
item, remarks, remarksby, date
a, &#039;good&#039;, &#039;sonu&#039; , day1
a, &#039;bad&#039;, monu&#039; , day2
d, &#039;too good&#039;, &#039;raju&#039; , day1
d, &#039;ok&#039;, &#039;golu&#039;  , day2

i have to show  like this...

item  , remarks1, remakrsby1, remarks2, remarksby2, remakrs3,remarksby3
a ,    good,         sonu,             bad,          monu
d,    too good ,    raju,             ok ,           golu 


please let me know how to do this ... ???
All thanks in advance]]></description>
		<content:encoded><![CDATA[<p>Good site..<br />
My query is&#8230;</p>
<p>i have 3 columns<br />
item, remarks, remarksby, date<br />
a, &#8216;good&#8217;, &#8216;sonu&#8217; , day1<br />
a, &#8216;bad&#8217;, monu&#8217; , day2<br />
d, &#8216;too good&#8217;, &#8216;raju&#8217; , day1<br />
d, &#8216;ok&#8217;, &#8216;golu&#8217;  , day2</p>
<p>i have to show  like this&#8230;</p>
<p>item  , remarks1, remakrsby1, remarks2, remarksby2, remakrs3,remarksby3<br />
a ,    good,         sonu,             bad,          monu<br />
d,    too good ,    raju,             ok ,           golu </p>
<p>please let me know how to do this &#8230; ???<br />
All thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RK</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-250063</link>
		<dc:creator><![CDATA[RK]]></dc:creator>
		<pubDate>Wed, 08 Feb 2012 16:49:36 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-250063</guid>
		<description><![CDATA[Did anyone reply? I am facing this same issue.]]></description>
		<content:encoded><![CDATA[<p>Did anyone reply? I am facing this same issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: preethis</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-212684</link>
		<dc:creator><![CDATA[preethis]]></dc:creator>
		<pubDate>Wed, 07 Dec 2011 10:18:00 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-212684</guid>
		<description><![CDATA[hi All, 
I have a requirement where the table values look like below
Parent ID is also a document ID. For each parent ID there may be one or more child document associated.           
Document ID	Document#	doc Name	Doc start date	end date	parent ID
101	0001	Aaa	1/1/90	1/2/90	334
102	0003	Sss	3/3/99	3/4/99	334
222	4566	Ano	5/5/05	6/6/06	null
334	9879	Parent	1/1/89	1/1/89	null

Now in my report, I need data as below
Document ID1	Doc start date1	end date1	DocumentID2	Doc start date2	end date2
101	1/1/90	1/2/90	102	3/3/99	3/4/99

please help 

thanks
preethi]]></description>
		<content:encoded><![CDATA[<p>hi All,<br />
I have a requirement where the table values look like below<br />
Parent ID is also a document ID. For each parent ID there may be one or more child document associated.<br />
Document ID	Document#	doc Name	Doc start date	end date	parent ID<br />
101	0001	Aaa	1/1/90	1/2/90	334<br />
102	0003	Sss	3/3/99	3/4/99	334<br />
222	4566	Ano	5/5/05	6/6/06	null<br />
334	9879	Parent	1/1/89	1/1/89	null</p>
<p>Now in my report, I need data as below<br />
Document ID1	Doc start date1	end date1	DocumentID2	Doc start date2	end date2<br />
101	1/1/90	1/2/90	102	3/3/99	3/4/99</p>
<p>please help </p>
<p>thanks<br />
preethi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harsha</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-198753</link>
		<dc:creator><![CDATA[Harsha]]></dc:creator>
		<pubDate>Fri, 18 Nov 2011 19:44:52 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-198753</guid>
		<description><![CDATA[Hi, i am currently working on a project where I have a column called &#039;Month&#039; which has months from Jan to Dec and correspondingly have a column called bill amount. I have to to display the bill amount for every month individually and then the sum of those . I am able to get the sum using PIVOT. But I am not able to display those values. Is  there any way that I can display the moth and then the sum?  Thank you.]]></description>
		<content:encoded><![CDATA[<p>Hi, i am currently working on a project where I have a column called &#8216;Month&#8217; which has months from Jan to Dec and correspondingly have a column called bill amount. I have to to display the bill amount for every month individually and then the sum of those . I am able to get the sum using PIVOT. But I am not able to display those values. Is  there any way that I can display the moth and then the sum?  Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amit D</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-194314</link>
		<dc:creator><![CDATA[Amit D]]></dc:creator>
		<pubDate>Sun, 13 Nov 2011 06:20:24 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-194314</guid>
		<description><![CDATA[Dear Atul,

Have u got any solution for the Problem.
please share  because i am also facing the same.

Please send me t]]></description>
		<content:encoded><![CDATA[<p>Dear Atul,</p>
<p>Have u got any solution for the Problem.<br />
please share  because i am also facing the same.</p>
<p>Please send me t</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vishal Parate</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-155377</link>
		<dc:creator><![CDATA[Vishal Parate]]></dc:creator>
		<pubDate>Tue, 09 Aug 2011 11:23:43 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-155377</guid>
		<description><![CDATA[in your example, while doing unpivot,  do we need to add pivot then unpivot.........

SELECT CUST, PRODUCT, QTY
FROM
(
SELECT CUST, VEG, SODA, MILK, BEER, CHIPS
FROM (
SELECT CUST, PRODUCT, QTY
FROM Product) up
PIVOT
( SUM(QTY) FOR PRODUCT IN (VEG, SODA, MILK, BEER, CHIPS)) AS pvt) p
UNPIVOT
(QTY FOR PRODUCT IN (VEG, SODA, MILK, BEER, CHIPS)
) AS Unpvt
GO

-------------------------------------------

here, you added pivot and unpivot.......

is there nay need of pivot]]></description>
		<content:encoded><![CDATA[<p>in your example, while doing unpivot,  do we need to add pivot then unpivot&#8230;&#8230;&#8230;</p>
<p>SELECT CUST, PRODUCT, QTY<br />
FROM<br />
(<br />
SELECT CUST, VEG, SODA, MILK, BEER, CHIPS<br />
FROM (<br />
SELECT CUST, PRODUCT, QTY<br />
FROM Product) up<br />
PIVOT<br />
( SUM(QTY) FOR PRODUCT IN (VEG, SODA, MILK, BEER, CHIPS)) AS pvt) p<br />
UNPIVOT<br />
(QTY FOR PRODUCT IN (VEG, SODA, MILK, BEER, CHIPS)<br />
) AS Unpvt<br />
GO</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>here, you added pivot and unpivot&#8230;&#8230;.</p>
<p>is there nay need of pivot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-147708</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 12 Jul 2011 14:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-147708</guid>
		<description><![CDATA[Search for PIVOT in this site]]></description>
		<content:encoded><![CDATA[<p>Search for PIVOT in this site</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rogger</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-147610</link>
		<dc:creator><![CDATA[Rogger]]></dc:creator>
		<pubDate>Tue, 12 Jul 2011 04:03:45 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-147610</guid>
		<description><![CDATA[Hi, i have this code, how it changes to sql server 2000 ??

TRANSFORM Count(dbo_CLIENTES.FECHA_CREACION) AS CuentaDeFECHA_CREACION
SELECT dbo_CLIENTES.CLI_EMPRESA AS EMPRESA
FROM dbo_C_CALZADO INNER JOIN dbo_CLIENTES ON dbo_C_CALZADO.ID_CLIENTES = dbo_CLIENTES.ID_CLIENTES
WHERE (((dbo_CLIENTES.EXTRANJERO)=&quot;TRUE&quot;))
GROUP BY dbo_CLIENTES.CLI_EMPRESA
ORDER BY dbo_CLIENTES.CLI_EMPRESA
PIVOT Year(DBO_CLIENTES.FECHA_CREACION);

Thanks a lot !!]]></description>
		<content:encoded><![CDATA[<p>Hi, i have this code, how it changes to sql server 2000 ??</p>
<p>TRANSFORM Count(dbo_CLIENTES.FECHA_CREACION) AS CuentaDeFECHA_CREACION<br />
SELECT dbo_CLIENTES.CLI_EMPRESA AS EMPRESA<br />
FROM dbo_C_CALZADO INNER JOIN dbo_CLIENTES ON dbo_C_CALZADO.ID_CLIENTES = dbo_CLIENTES.ID_CLIENTES<br />
WHERE (((dbo_CLIENTES.EXTRANJERO)=&#8221;TRUE&#8221;))<br />
GROUP BY dbo_CLIENTES.CLI_EMPRESA<br />
ORDER BY dbo_CLIENTES.CLI_EMPRESA<br />
PIVOT Year(DBO_CLIENTES.FECHA_CREACION);</p>
<p>Thanks a lot !!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Penchal Reddy.U</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-146643</link>
		<dc:creator><![CDATA[Penchal Reddy.U]]></dc:creator>
		<pubDate>Thu, 07 Jul 2011 12:32:06 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-146643</guid>
		<description><![CDATA[Hi All,
         
I created  a table  as shown below.By using ssis package DeptID 10 data should be transfered into seperate table ,DeptID 20 data should be transfered into seperate table.....but  the condition is that when i  entered DeptID 50,60......in the original table for each  and every DeptID seperate tables should be  created in the Database when i  run the package.can anyone give clue for this pls......

DeptID	DeptName	Location
10	computers	chennai
10	computers	Hyd
20	electronics	Delhi
20	electronics	Hyd
20	electronics	mumbai
30	commerce	CPT
30	commerce	Gunture
30	commerce	NRT
30	commerce	VNK
40	maths	                BAD


Thanks,
U.Penchal Reddy.]]></description>
		<content:encoded><![CDATA[<p>Hi All,</p>
<p>I created  a table  as shown below.By using ssis package DeptID 10 data should be transfered into seperate table ,DeptID 20 data should be transfered into seperate table&#8230;..but  the condition is that when i  entered DeptID 50,60&#8230;&#8230;in the original table for each  and every DeptID seperate tables should be  created in the Database when i  run the package.can anyone give clue for this pls&#8230;&#8230;</p>
<p>DeptID	DeptName	Location<br />
10	computers	chennai<br />
10	computers	Hyd<br />
20	electronics	Delhi<br />
20	electronics	Hyd<br />
20	electronics	mumbai<br />
30	commerce	CPT<br />
30	commerce	Gunture<br />
30	commerce	NRT<br />
30	commerce	VNK<br />
40	maths	                BAD</p>
<p>Thanks,<br />
U.Penchal Reddy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Penchal Reddy.U</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-144376</link>
		<dc:creator><![CDATA[Penchal Reddy.U]]></dc:creator>
		<pubDate>Tue, 28 Jun 2011 10:11:45 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-144376</guid>
		<description><![CDATA[thanx madhivanan......it is working..,..


regards
penchal reddy.u]]></description>
		<content:encoded><![CDATA[<p>thanx madhivanan&#8230;&#8230;it is working..,..</p>
<p>regards<br />
penchal reddy.u</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lisa</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-143293</link>
		<dc:creator><![CDATA[Lisa]]></dc:creator>
		<pubDate>Thu, 23 Jun 2011 22:04:37 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-143293</guid>
		<description><![CDATA[I had a hard time finding useful articles for a beginner like me, but this was an excellent article! Thanks so much]]></description>
		<content:encoded><![CDATA[<p>I had a hard time finding useful articles for a beginner like me, but this was an excellent article! Thanks so much</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pramod</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-141064</link>
		<dc:creator><![CDATA[Pramod]]></dc:creator>
		<pubDate>Wed, 15 Jun 2011 11:31:19 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-141064</guid>
		<description><![CDATA[Build a dynamic query instead, this will work for you :)]]></description>
		<content:encoded><![CDATA[<p>Build a dynamic query instead, this will work for you :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-140196</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Fri, 10 Jun 2011 08:28:31 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-140196</guid>
		<description><![CDATA[Search for UNPIVOT in this site]]></description>
		<content:encoded><![CDATA[<p>Search for UNPIVOT in this site</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Penchal Reddy.U</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-139939</link>
		<dc:creator><![CDATA[Penchal Reddy.U]]></dc:creator>
		<pubDate>Thu, 09 Jun 2011 04:46:20 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-139939</guid>
		<description><![CDATA[Hi all,

       I am having a table containing data in the below format in sql server.
   
Person	Day1	Day2         	Day3        	Day4	 val
Penchal        45	58	44	98	NULL
Venkat          44	59	78	23	NULL
Vijay              48	60	66	54	NULL   


Let me know the hw to make the above data as below.   

Person        Day        val
Penchal      Day1       45
Penchal      Day2       58
Penchal      Day3       44
Penchal      Day4       98
Venkat         Day1       44
venkat          Day2       59
Venkat         Day3       78
venkat          Day4       23
.
.
.
.
.
.
Regards,
U.Penchal Reddy.]]></description>
		<content:encoded><![CDATA[<p>Hi all,</p>
<p>       I am having a table containing data in the below format in sql server.</p>
<p>Person	Day1	Day2         	Day3        	Day4	 val<br />
Penchal        45	58	44	98	NULL<br />
Venkat          44	59	78	23	NULL<br />
Vijay              48	60	66	54	NULL   </p>
<p>Let me know the hw to make the above data as below.   </p>
<p>Person        Day        val<br />
Penchal      Day1       45<br />
Penchal      Day2       58<br />
Penchal      Day3       44<br />
Penchal      Day4       98<br />
Venkat         Day1       44<br />
venkat          Day2       59<br />
Venkat         Day3       78<br />
venkat          Day4       23<br />
.<br />
.<br />
.<br />
.<br />
.<br />
.<br />
Regards,<br />
U.Penchal Reddy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: manoj</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-139683</link>
		<dc:creator><![CDATA[manoj]]></dc:creator>
		<pubDate>Wed, 08 Jun 2011 10:59:40 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-139683</guid>
		<description><![CDATA[dear sir i just want to convert columns to row in sql server.  is it possible with pivot?]]></description>
		<content:encoded><![CDATA[<p>dear sir i just want to convert columns to row in sql server.  is it possible with pivot?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-133974</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 11 May 2011 13:58:58 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-133974</guid>
		<description><![CDATA[Look for PIVOT in SQL Server help file]]></description>
		<content:encoded><![CDATA[<p>Look for PIVOT in SQL Server help file</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Huynh Van Vu</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-133937</link>
		<dc:creator><![CDATA[Huynh Van Vu]]></dc:creator>
		<pubDate>Wed, 11 May 2011 07:22:09 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-133937</guid>
		<description><![CDATA[hi

how to use PIVOT in SQL Server 2000?]]></description>
		<content:encoded><![CDATA[<p>hi</p>
<p>how to use PIVOT in SQL Server 2000?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-133812</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 10 May 2011 12:37:08 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-133812</guid>
		<description><![CDATA[Post some sample data with expected result]]></description>
		<content:encoded><![CDATA[<p>Post some sample data with expected result</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pallavi</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-133801</link>
		<dc:creator><![CDATA[Pallavi]]></dc:creator>
		<pubDate>Tue, 10 May 2011 11:07:18 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-133801</guid>
		<description><![CDATA[Hi,

I wants to show cross matrix which will contain data like

                       Monday    Tuesday,..... Friday
Client               xyz           xxx
Subject            testemail   test
owner              ABC          CCC


Please let me know how it can be done?]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I wants to show cross matrix which will contain data like</p>
<p>                       Monday    Tuesday,&#8230;.. Friday<br />
Client               xyz           xxx<br />
Subject            testemail   test<br />
owner              ABC          CCC</p>
<p>Please let me know how it can be done?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abdul</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-124238</link>
		<dc:creator><![CDATA[Abdul]]></dc:creator>
		<pubDate>Mon, 21 Mar 2011 10:11:48 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-124238</guid>
		<description><![CDATA[Great Job, 
Really helpfull. Thanks a lot]]></description>
		<content:encoded><![CDATA[<p>Great Job,<br />
Really helpfull. Thanks a lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Clerbois</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-121901</link>
		<dc:creator><![CDATA[Daniel Clerbois]]></dc:creator>
		<pubDate>Fri, 04 Mar 2011 20:50:22 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-121901</guid>
		<description><![CDATA[Hello there,
thank you for the explanation, it &#039;been useful in my current project though I still have a concern;
Iwas wondering if it&#039;s possible to generate dynamically the fields contained in the pivot.

A typical case would be to get sum of products based on a period, let&#039;s say for instance between 12months as from current month;
This way, the result shown would be constantly moving from month to month and would only display the last 12 ones.
So far I only can  display 12 fixed months from JAN to DEC with an additonal parameter forcing the user to change the current year.]]></description>
		<content:encoded><![CDATA[<p>Hello there,<br />
thank you for the explanation, it &#8216;been useful in my current project though I still have a concern;<br />
Iwas wondering if it&#8217;s possible to generate dynamically the fields contained in the pivot.</p>
<p>A typical case would be to get sum of products based on a period, let&#8217;s say for instance between 12months as from current month;<br />
This way, the result shown would be constantly moving from month to month and would only display the last 12 ones.<br />
So far I only can  display 12 fixed months from JAN to DEC with an additonal parameter forcing the user to change the current year.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jayendra</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-121331</link>
		<dc:creator><![CDATA[Jayendra]]></dc:creator>
		<pubDate>Tue, 01 Mar 2011 09:26:04 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-121331</guid>
		<description><![CDATA[Can you Please Post the query for following of this]]></description>
		<content:encoded><![CDATA[<p>Can you Please Post the query for following of this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jayendra</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-121330</link>
		<dc:creator><![CDATA[Jayendra]]></dc:creator>
		<pubDate>Tue, 01 Mar 2011 09:25:19 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-121330</guid>
		<description><![CDATA[Data Before Pivot&gt;&gt;

Product_Family	 Country_Code	 Day_Actual_Revenue MTD_Actual_Revenue	YTD_Actual_Revenue	MTD_Expected_Revenue	YTD_Expected_Revenue	MTD_Index_Revenue	YTD_Index_Revenue	Day_Actual_Units	MTD_Actual_Units	YTD_Actual_Units	MTD_Expected_Units	YTD_Expected_Units	MTD_Index_Units	YTD_Index_Units
HAIR	US	2970.000	551709.000	1199355.000	464062.500	1039500.000	119.000	115.000	6.000	1103.000	2392.000	937.500	2100.000	118.000	114.000
ACNE	US	245.000	32565.200	68877.000	56250.000	126000.000	58.000	55.000	1.000	127.000	277.000	250.000	560.000	51.000	49.000


Data After Pivot &gt;&gt;&gt;

Type(Rev or Units)	Label	Hair_Avg	Hair_Index	Acne_Avg	Acne_Index	Total_Avg	Total_Index
Revenue	Day	2970		245		3215	
Revenue	MTD	22068.36	119	1302.61	58	23370.97	112.29
Revenue	YTD	21417.05	115	1229.95	55	22647	108.81
Units	Day	6		1			
Units	MTD	44.12	118	5.08	51		
Units	YTD	42.71	114	4.95	49]]></description>
		<content:encoded><![CDATA[<p>Data Before Pivot&gt;&gt;</p>
<p>Product_Family	 Country_Code	 Day_Actual_Revenue MTD_Actual_Revenue	YTD_Actual_Revenue	MTD_Expected_Revenue	YTD_Expected_Revenue	MTD_Index_Revenue	YTD_Index_Revenue	Day_Actual_Units	MTD_Actual_Units	YTD_Actual_Units	MTD_Expected_Units	YTD_Expected_Units	MTD_Index_Units	YTD_Index_Units<br />
HAIR	US	2970.000	551709.000	1199355.000	464062.500	1039500.000	119.000	115.000	6.000	1103.000	2392.000	937.500	2100.000	118.000	114.000<br />
ACNE	US	245.000	32565.200	68877.000	56250.000	126000.000	58.000	55.000	1.000	127.000	277.000	250.000	560.000	51.000	49.000</p>
<p>Data After Pivot &gt;&gt;&gt;</p>
<p>Type(Rev or Units)	Label	Hair_Avg	Hair_Index	Acne_Avg	Acne_Index	Total_Avg	Total_Index<br />
Revenue	Day	2970		245		3215<br />
Revenue	MTD	22068.36	119	1302.61	58	23370.97	112.29<br />
Revenue	YTD	21417.05	115	1229.95	55	22647	108.81<br />
Units	Day	6		1<br />
Units	MTD	44.12	118	5.08	51<br />
Units	YTD	42.71	114	4.95	49</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepti</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-111992</link>
		<dc:creator><![CDATA[Deepti]]></dc:creator>
		<pubDate>Wed, 19 Jan 2011 07:32:48 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-111992</guid>
		<description><![CDATA[SELECT &#039;Title&#039; AS Sort_By_Title, 
[Sales Representative], [Vice President, Sales], [Sales Manager], [Inside Sales Coordinator]
FROM
(SELECT FirstName,Title  FROM dbo.Employees) AS SourceTable
PIVOT
(
MAX(FirstName)
FOR Title IN 
([Sales Representative], [Vice President, Sales], [Sales Manager], [Inside Sales Coordinator])
) AS PivotTable;

Incorrect syntax err. Can someone suggest?]]></description>
		<content:encoded><![CDATA[<p>SELECT &#8216;Title&#8217; AS Sort_By_Title,<br />
[Sales Representative], [Vice President, Sales], [Sales Manager], [Inside Sales Coordinator]<br />
FROM<br />
(SELECT FirstName,Title  FROM dbo.Employees) AS SourceTable<br />
PIVOT<br />
(<br />
MAX(FirstName)<br />
FOR Title IN<br />
([Sales Representative], [Vice President, Sales], [Sales Manager], [Inside Sales Coordinator])<br />
) AS PivotTable;</p>
<p>Incorrect syntax err. Can someone suggest?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sqltutorial</title>
		<link>http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/#comment-110304</link>
		<dc:creator><![CDATA[sqltutorial]]></dc:creator>
		<pubDate>Mon, 10 Jan 2011 09:50:54 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=638#comment-110304</guid>
		<description><![CDATA[thanks a lot for share this sql tricky]]></description>
		<content:encoded><![CDATA[<p>thanks a lot for share this sql tricky</p>
]]></content:encoded>
	</item>
</channel>
</rss>

