pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Kurt Overberg <kurt@hotdogrecords.com>
To: pgsql-sql@postgresql.org
Subject: Re: Selecting rows as if they were columns?
Date: Thu, 9 Oct 2003 10:14:09 -0700
Message-ID: <200310091014.09695.josh@agliodbs.com> (raw)
In-Reply-To: <3F855F38.9070803@hotdogrecords.com>
References: <3F855F38.9070803@hotdogrecords.com>

Kurt,

> I've got what I think should be a pretty simple problem- I just can't
> figure out how I'd do it.  Heck, I can't even figure out how I'd search
> for an answer to this problem.

This is an old common SQL problem ... the "crosstab" table.   There are 3 
standard ways to solve it, depending on the exact circumstances of your case.   
It's probably best if you buy Joe Celko's "SQL for Smarties, 2nd Ed.", which 
has a 50-page chapter on the topic and explores the methods in detail.

-- 
Josh Berkus
Aglio Database Solutions
San Francisco



view thread (4+ messages)  latest in thread

Message-ID: <200310091014.09695.josh@agliodbs.com>
Permalink:  ../200310091014.09695.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200310091014.09695.josh@agliodbs.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: josh@agliodbs.com, kurt@hotdogrecords.com
  Subject: Re: Selecting rows as if they were columns?
  In-Reply-To: <200310091014.09695.josh@agliodbs.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