Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Toc8i-0001zn-3s for pgsql-sql@arkaria.postgresql.org; Fri, 28 Dec 2012 15:46:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Toc8h-0000J2-4N for pgsql-sql@arkaria.postgresql.org; Fri, 28 Dec 2012 15:46:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Toc8g-0000Ix-I5 for pgsql-sql@postgresql.org; Fri, 28 Dec 2012 15:46:26 +0000 Received: from mailout02.ims-firmen.de ([213.174.32.97]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Toc8e-0004Hz-CT for pgsql-sql@postgresql.org; Fri, 28 Dec 2012 15:46:26 +0000 Received: from mailin01.ims-firmen.de ([192.168.1.141]) by mailout02.ims-firmen.de with esmtp (envelope-from ) id 1Toc8e-00020l-jL; Fri, 28 Dec 2012 16:46:24 +0100 Received: from [213.174.32.191] (helo=oxweb01.ims-firmen.de) by mailin01.ims-firmen.de with esmtpsa (TLSv1:RC4-MD5:128) (envelope-from ) id 1Toc8e-0001Sr-01; Fri, 28 Dec 2012 16:46:24 +0100 Date: Fri, 28 Dec 2012 16:42:59 +0100 (CET) From: Andreas Kretschmer Reply-To: Andreas Kretschmer To: pgsql-sql@postgresql.org, JORGE MALDONADO Message-ID: <827851602.423235.1356709379875.JavaMail.open-xchange@ox.ims-firmen.de> In-Reply-To: References: Subject: Re: Help with a select statement design MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v6.20.6-Rev4 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org JORGE MALDONADO hat am 24. Dezember 2012 um 17:30 geschrieben: > I have a record with the following fields: > > id1, id2, id3, id4, price1, price2, price3, price4 > > I would like to write a SELECT statement in order to get 4 records: > > id, price (record that comes from id1 and price 1) > id, price (record that comes from id2 and price 2) > id, price (record that comes from id3 and price 3) > id, price (record that comes from id4 and price 4) > > I will very much appreciate any suggestion. > > Respectfully, > Jorge Maldonado select id1 as id, price1 as price union all select id2, price2 union all select id3, ... you got it? Andreas -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql