Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BAA8A475FD4 for ; Fri, 13 Sep 2002 19:18:52 -0400 (EDT) Received: from newsguy.com (smtp.newsguy.com [216.148.53.69]) by postgresql.org (Postfix) with ESMTP id F38C8475FC4 for ; Fri, 13 Sep 2002 19:18:51 -0400 (EDT) Received: (from pacquet@localhost) by newsguy.com (8.9.1a/8.9.1) id QAA09972 for pgsql-sql@postgresql.org; Fri, 13 Sep 2002 16:18:54 -0700 (PDT) Date: Fri, 13 Sep 2002 16:18:54 -0700 (PDT) Message-Id: <200209132318.QAA09972@newsguy.com> X-Mailer: Direct Read Email by Newsguy News Service To: pgsql-sql@postgresql.org From: pacquet@newsguy.com Subject: "Inverting" a table, OLAP-style X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/167 X-Sequence-Number: 9444 I have a data-collection app, which creates a table like this, more or less: t timestamp name varchar value numeric the number of distinct values of is 800 and growing, besides being data-dependent, so it might be pretty inconvenient to have a single table with 800 columns. (and we might exceed the 1600-column limit someday) But clients WOULD like to view the data sometimes as though it were: t x y z ---------------------------------------------------------------- t1 value when name='x' value when name='y' value when name='z' if they do a SELECT on time=t1 and (name='x' or name='y' or name='z') This seems like a fairly common desire. I know we could use Pivot Tables in Excel, or otherwise do it on the client, but the highest-leverage solution would be to present this abstraction in the server. Any ideas on how to do this?