pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: Richard Huxton <dev@archonet.com>
Cc: Christoph Haller <ch@rodos.fzk.de>
Cc: pgsql-sql@postgresql.org
Cc: terry@ashtonwoodshomes.com
Cc: chaudhar@umich.edu
Subject: Re: Generating a cross tab (pivot table)
Date: Thu, 07 Nov 2002 09:25:37 -0800
Message-ID: <3DCAA211.3020402@joeconway.com> (raw)
References: <3DCA52E2.5529E893@rodos.fzk.de>
	<200211071215.32235.dev@archonet.com>

Richard Huxton wrote:
> On Thursday 07 Nov 2002 11:47 am, Christoph Haller wrote:
> 
>>Regarding to Terry's request on multiple aggregates and
>>Shahbaz's request for generating a cross tab ( pivot table )
>>in September, I've found an excellent example on a german inet page
>>http://www.itrain.de/
>>I've translated it and think it's useful for many who subscribed
>>(I hope so, maybe it was told before, but I couldn't find
>>anything about this topic in the techdecs).
> 
> Very useful. Also note there are some examples of how to produce crosstab 
> results in the table-functions contrib directory in 7.3
> 

Just to amplify a bit, in contrib/tablefunc there is a family of functions 
called crosstabN(), where N is 2, 3 and 4. These are meant as examples -- you 
could, for example, create a function crosstab5() if you need it. There is 
also a function called crosstab(), which returns type RECORD and thus requires 
the column definition to be specified in the query. See 
contrib/tablefunc/README.tablefunc for more details and examples.

These were done as relatively crude examples and therefore have some 
limitations which may or may not be a problem for you. If people find the 
functions useful and provide suggestions for improvement in functionality I'll 
try to upgrade them for 7.4.

Thanks,

Joe




view thread (6+ messages)  latest in thread

Message-ID: <3DCAA211.3020402@joeconway.com>
Permalink:  ../3DCAA211.3020402@joeconway.com/
Also on:    postgresql.org/message-id/3DCAA211.3020402@joeconway.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mail@joeconway.com, dev@archonet.com, ch@rodos.fzk.de, terry@ashtonwoodshomes.com, chaudhar@umich.edu
  Subject: Re: Generating a cross tab (pivot table)
  In-Reply-To: <3DCAA211.3020402@joeconway.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox