transposing data for a view

From: jeremy(at)wundt(dot)psychiatry(dot)uiowa(dot)edu (H Jeremy Bockholt)
To: pgsql-sql(at)postgresql(dot)org
Subject: transposing data for a view
Date: 2001-10-31 00:36:17
Message-ID: b773797b.0110301636.5af6bd25@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have a generalized table:

scanid | region | volume
-------------------------
1 A 34.4
1 B 32.1
1 C 29.1
2 A 32.4
2 B 33.2
2 C 35.6
.
.
.

I want to create a flattened out view that looks like the following:

scanid | A_volume | B_volume | C_volume
----------------------------------------
1 34.4 32.1 29.1
2 32.4 33.2 35.6
.
.
.

How do I correctly/efficiently construct a psql query to
pivot/transpose the data? I am using postgreSQL version 7.0.x

thanks,
Jeremy

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message sharmad 2001-10-31 05:42:37 Re: postgresql error
Previous Message Tom Lane 2001-10-30 22:20:31 Re: Strange loop