<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PIVOT PostgreSQL &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/pivot-postgresql/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Tue, 24 Apr 2018 19:56:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>PostgreSQL: Example of CROSSTAB query, for PIVOT arrangement</title>
		<link>https://www.dbrnd.com/2018/04/postgresql-example-of-crosstab-query-for-pivot-arrangement/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 26 Apr 2018 16:16:00 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[CROSSTAB Pivot]]></category>
		<category><![CDATA[CROSSTAB View]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[PIVOT PostgreSQL]]></category>
		<category><![CDATA[PIVOT Query]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Monitoring]]></category>
		<category><![CDATA[PostgreSQL Performance Tuning]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[tablefunc]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=7444</guid>

					<description><![CDATA[In this post, I am sharing an example of CROSSTAB query of PostgreSQL. The &#8220;tablefunc&#8221; module provides the CROSSTAB() which uses for displaying data from rows to columns. I already shared few similar articles on PostgreSQL PIVOT and new CROSSTABVIEW. PostgreSQL: CREATE PIVOT TABLE to arrange Rows into Columns form PostgreSQL 9.6: Introduced CROSSTABVIEW (pivot) [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-example-of-crosstab-query-for-pivot-arrangement%2F&amp;linkname=PostgreSQL%3A%20Example%20of%20CROSSTAB%20query%2C%20for%20PIVOT%20arrangement" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-example-of-crosstab-query-for-pivot-arrangement%2F&amp;linkname=PostgreSQL%3A%20Example%20of%20CROSSTAB%20query%2C%20for%20PIVOT%20arrangement" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-example-of-crosstab-query-for-pivot-arrangement%2F&amp;linkname=PostgreSQL%3A%20Example%20of%20CROSSTAB%20query%2C%20for%20PIVOT%20arrangement" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-example-of-crosstab-query-for-pivot-arrangement%2F&amp;linkname=PostgreSQL%3A%20Example%20of%20CROSSTAB%20query%2C%20for%20PIVOT%20arrangement" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-example-of-crosstab-query-for-pivot-arrangement%2F&amp;linkname=PostgreSQL%3A%20Example%20of%20CROSSTAB%20query%2C%20for%20PIVOT%20arrangement" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-example-of-crosstab-query-for-pivot-arrangement%2F&amp;linkname=PostgreSQL%3A%20Example%20of%20CROSSTAB%20query%2C%20for%20PIVOT%20arrangement" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2018%2F04%2Fpostgresql-example-of-crosstab-query-for-pivot-arrangement%2F&#038;title=PostgreSQL%3A%20Example%20of%20CROSSTAB%20query%2C%20for%20PIVOT%20arrangement" data-a2a-url="https://www.dbrnd.com/2018/04/postgresql-example-of-crosstab-query-for-pivot-arrangement/" data-a2a-title="PostgreSQL: Example of CROSSTAB query, for PIVOT arrangement"></a></p><p>In this post, I am sharing an example of CROSSTAB query of PostgreSQL. The &#8220;tablefunc&#8221; module provides the CROSSTAB() which uses for displaying data from rows to columns.</p>
<p>I already shared few similar articles on PostgreSQL PIVOT and new CROSSTABVIEW.</p>
<blockquote class="wp-embedded-content" data-secret="2t3E5KKqNX"><p><a href="https://www.dbrnd.com/2016/09/postgresql-create-pivot-table-to-arrange-rows-into-columns-form-using-group-by-clause/">PostgreSQL: CREATE PIVOT TABLE to arrange Rows into Columns form</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/09/postgresql-create-pivot-table-to-arrange-rows-into-columns-form-using-group-by-clause/embed/#?secret=2t3E5KKqNX" data-secret="2t3E5KKqNX" width="600" height="338" title="&#8220;PostgreSQL: CREATE PIVOT TABLE to arrange Rows into Columns form&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote class="wp-embedded-content" data-secret="5bVN8SQ4XK"><p><a href="https://www.dbrnd.com/2017/04/postgresql-9-6-introduced-crosstabview-pivot-in-psql/">PostgreSQL 9.6: Introduced CROSSTABVIEW (pivot) in PSQL</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2017/04/postgresql-9-6-introduced-crosstabview-pivot-in-psql/embed/#?secret=5bVN8SQ4XK" data-secret="5bVN8SQ4XK" width="600" height="338" title="&#8220;PostgreSQL 9.6: Introduced CROSSTABVIEW (pivot) in PSQL&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Please check the below demonstration:</strong></p>
<p><strong>Create a required extension:</strong></p><pre class="crayon-plain-tag">CREATE EXTENSION tablefunc;</pre><p>
<p><strong>Create sample table with data:</strong></p><pre class="crayon-plain-tag">CREATE TEMP TABLE test_crosstab
(
    Product_Name TEXT
    ,Product_Category TEXT
    ,Product_Count INT
);

INSERT INTO test_crosstab
VALUES
('Mobile','IT',20)
,('Mobile','ELE',40)
,('Desktop','IT',50)
,('Desktop','ELE',60)
,('Laptop','IT',30)
,('Laptop','ELE',70);</pre><p>
<img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-7448" src="https://www.dbrnd.com/wp-content/uploads/2018/04/PostgreSQL-Sample-Data.png" alt="PostgreSQL Sample Data" width="733" height="194" srcset="https://www.dbrnd.com/wp-content/uploads/2018/04/PostgreSQL-Sample-Data.png 733w, https://www.dbrnd.com/wp-content/uploads/2018/04/PostgreSQL-Sample-Data-679x180.png 679w" sizes="(max-width: 733px) 100vw, 733px" /></p>
<p><strong>Use CROSSTAB for displaying data from rows to columns:</strong></p><pre class="crayon-plain-tag">SELECT * 
FROM CROSSTAB
(
    	'SELECT Product_Name, Product_Category, Product_Count
    	 FROM test_crosstab
    	 ORDER BY 1,2'
)AS T (Product_Name text, IT INT, ELE INT)</pre><p>
<strong>Result:</strong></p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-7447" src="https://www.dbrnd.com/wp-content/uploads/2018/04/PostgreSQL-Crosstab.png" alt="PostgreSQL Crosstab" width="510" height="163" /></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
