Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B6903476A66 for ; Wed, 11 Dec 2002 11:22:12 -0500 (EST) Received: from natura.cebas.csic.es (natura.cebas.csic.es [161.111.146.9]) by postgresql.org (Postfix) with ESMTP id 771634767C4 for ; Wed, 11 Dec 2002 11:22:08 -0500 (EST) Received: from natura.cebas.csic.es (localhost.localdomain [127.0.0.1]) by natura.cebas.csic.es (8.11.6/8.11.6) with ESMTP id gBBGG4829508 for ; Wed, 11 Dec 2002 17:16:04 +0100 Received: from there (equipo97.cebas.csic.es [161.111.146.97]) by natura.cebas.csic.es (8.11.6/8.11.6) with SMTP id gBBGG3Q29502 for ; Wed, 11 Dec 2002 17:16:03 +0100 Message-Id: <200212111616.gBBGG3Q29502@natura.cebas.csic.es> Content-Type: text/plain; charset="iso-8859-15" From: javier garcia Organization: CEBAS-CSIC To: "pgsql-sql@postgresql.org" Subject: union query doubt: Date: Wed, 11 Dec 2002 17:21:43 +0100 X-Mailer: KMail [version 1.3.2] MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/127 X-Sequence-Number: 10715 Hi; I've got a table with three fields: DATE, POINT, FLOW. The POINT field can have values among 1 and 6. So, for a same date I have six different points with the correspondings flows. I would like to make a query to obtain something like: DATE POINT1 POINT2 POINT3 POINT4 POINT5 POINT6 where for a date I have the flows data of the different points. I think that I would need to establish different alias for the same field. Is this possible? Perhaps something like: SELECT date, flow AS POINT1 FROM samples WHERE POINT=1 UNION ALL SELECT date, flow AS POINT2 FROM samples WHERE POINT=2 UNION ALL SELECT date, flow AS POINT3 FROM samples WHERE POINT=3 ...; and a SELECT over the result of this subselect, that groups by date, or so? Thanks for you help. Javier