<?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>CROSSTABVIEW &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/crosstabview/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>Sun, 02 Apr 2017 14:52:09 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>PostgreSQL 9.6: Introduced CROSSTABVIEW (pivot) in PSQL</title>
		<link>https://www.dbrnd.com/2017/04/postgresql-9-6-introduced-crosstabview-pivot-in-psql/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 12 Apr 2017 16:16:04 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[crosstab]]></category>
		<category><![CDATA[CROSSTABVIEW]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Pivot]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL 9.6]]></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[psql]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5020</guid>

					<description><![CDATA[In this post, I am sharing a new feature CROSSTABVIEW in PSQL of PostgreSQL 9.6. Many times we require data arrangement horizontally, instead of vertically. Something like we are doing in a spreadsheet where one element has a multiple child elements and require calculation horizontally for each group of items. Now, you can use CROSSTABVIEW [&#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%2F2017%2F04%2Fpostgresql-9-6-introduced-crosstabview-pivot-in-psql%2F&amp;linkname=PostgreSQL%209.6%3A%20Introduced%20CROSSTABVIEW%20%28pivot%29%20in%20PSQL" 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%2F2017%2F04%2Fpostgresql-9-6-introduced-crosstabview-pivot-in-psql%2F&amp;linkname=PostgreSQL%209.6%3A%20Introduced%20CROSSTABVIEW%20%28pivot%29%20in%20PSQL" 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%2F2017%2F04%2Fpostgresql-9-6-introduced-crosstabview-pivot-in-psql%2F&amp;linkname=PostgreSQL%209.6%3A%20Introduced%20CROSSTABVIEW%20%28pivot%29%20in%20PSQL" 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%2F2017%2F04%2Fpostgresql-9-6-introduced-crosstabview-pivot-in-psql%2F&amp;linkname=PostgreSQL%209.6%3A%20Introduced%20CROSSTABVIEW%20%28pivot%29%20in%20PSQL" 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%2F2017%2F04%2Fpostgresql-9-6-introduced-crosstabview-pivot-in-psql%2F&amp;linkname=PostgreSQL%209.6%3A%20Introduced%20CROSSTABVIEW%20%28pivot%29%20in%20PSQL" 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%2F2017%2F04%2Fpostgresql-9-6-introduced-crosstabview-pivot-in-psql%2F&amp;linkname=PostgreSQL%209.6%3A%20Introduced%20CROSSTABVIEW%20%28pivot%29%20in%20PSQL" 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%2F2017%2F04%2Fpostgresql-9-6-introduced-crosstabview-pivot-in-psql%2F&#038;title=PostgreSQL%209.6%3A%20Introduced%20CROSSTABVIEW%20%28pivot%29%20in%20PSQL" data-a2a-url="https://www.dbrnd.com/2017/04/postgresql-9-6-introduced-crosstabview-pivot-in-psql/" data-a2a-title="PostgreSQL 9.6: Introduced CROSSTABVIEW (pivot) in PSQL"></a></p><p>In this post, I am sharing a new feature CROSSTABVIEW in PSQL of PostgreSQL 9.6. Many times we require data arrangement horizontally, instead of vertically. </p>
<p>Something like we are doing in a spreadsheet where one element has a multiple child elements and require calculation horizontally for each group of items.</p>
<p>Now, you can use CROSSTABVIEW in new PSQL for this kind of requirement.</p>
<p><strong>Below is a small demonstration of this:</strong></p>
<p><strong>Open a psql command line and create a below sample table:</strong></p>
<pre class="crayon-plain-tag">create table tbl_range as
select
    ('{a,b,c,d,e,f}'::text[])[1 + floor(random() * 6)] as data1
    ,('{g,h,i,j,k,l}'::text[])[1 + floor(random() * 6)] as data2
    ,random() * 1000 as randomnumber
from generate_series(1,10000);</pre> </p>
<p><strong>Execute below few SELECTs:</strong></p>
<pre class="crayon-plain-tag">select * from tbl_range;
select data1, data2, count(*) from tbl_range group by data1, data2;</pre> </p>
<p><strong>Now check sample SELECT with CROSSTABVIEW:</strong></p>
<pre class="crayon-plain-tag">select data1, data2, count(*) from tbl_range group by data1, data2 \crosstabview data1 data2 count;</pre> </p>
<p><strong>The result:</strong></p>
<pre class="crayon-plain-tag">dbrnd=# select data1, data2, count(*) from tbl_range group by data1, data2 \crosstabview data1 data2 count;
 data1 |  k  |  j  |  i  |  h  |  g  |  l
-------+-----+-----+-----+-----+-----+-----
 f     | 281 | 273 | 261 | 265 | 268 | 258
 a     | 288 | 293 | 278 | 293 | 248 | 279
 d     | 293 | 264 | 278 | 258 | 289 | 291
 c     | 272 | 276 | 292 | 287 | 263 | 281
 e     | 269 | 279 | 281 | 257 | 274 | 318
 b     | 289 | 270 | 301 | 295 | 247 | 291
(6 rows)</pre> </p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
