Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f9V16FP99613 for ; Tue, 30 Oct 2001 20:06:15 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id f9V0aO460475 for pgsql-sql@postgresql.org; Tue, 30 Oct 2001 19:36:24 -0500 (EST) (envelope-from news) From: jeremy@wundt.psychiatry.uiowa.edu (H Jeremy Bockholt) X-Newsgroups: comp.databases.postgresql.sql Subject: transposing data for a view Date: 30 Oct 2001 16:36:17 -0800 Organization: http://groups.google.com/ Lines: 29 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Archive-Number: 200110/427 X-Sequence-Number: 5378 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