Received: from [195.84.61.166] ([195.84.61.166]) by hub.org (8.10.1/8.10.1) with SMTP id e73FPQG68443 for ; Thu, 3 Aug 2000 11:25:26 -0400 (EDT) Message-Id: From: Dana.Reed@clinicaldatacare.com Received: from lutfs.clinicaldatacare.com by [195.84.61.166] via smtpd (for postgresql.org [216.126.84.28]) with SMTP; 3 Aug 2000 15:11:03 UT Date: Thu, 3 Aug 2000 17:24:13 +0000 To: pgsql-sql@postgresql.org Receipt-Requested-To: Dana.Reed@clinicaldatacare.com Subject: SQL (table transposition) MIME-version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Mailer: TFS Secure Messaging /320000000/460220005/460220004/460220009/ X-Mailer: Version 4.6 Build 117 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by hub.org id e73FPRG68446 X-Archive-Number: 200008/25 Is there any way to get table T3 (below) from T1 and T2 using SQL (select, view, etc)? T3 is basically all INDEX values from T1 matched to IND from T2 with the corresponding KEY/VALUE pairs transposed from rows to columns. ------- |INDEX| (T1) ------- | 1 | | 2 | | 3 | ------- ----------------- |IND|KEY| VALUE | (T2) ----------------- | 1 | 1 | val_a | | 1 | 2 | val_b | | 1 | 3 | val_c | | 2 | 1 | val_d | | 2 | 2 | val_e | | 3 | 1 | val_f | | 3 | 3 | val_g | ----------------- ---------------------------------- |T1_INDEX|KEY1VAL|KEY2VAL|KEY3VAL| (T3) ---------------------------------- | 1 | val_a | val_b | val_c | | 2 | val_d | val_e | | | 3 | val_f | | val_g | ---------------------------------- Thanks for any suggestions med vänlig hälsning /Dana