pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: javier garcia <andresjavier.garcia@wanadoo.es>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: union query doubt:
Date: Wed, 11 Dec 2002 17:21:43 +0100
Message-ID: <200212111616.gBBGG3Q29502@natura.cebas.csic.es> (raw)

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



view thread (3+ messages)  latest in thread

Message-ID: <200212111616.gBBGG3Q29502@natura.cebas.csic.es>
Permalink:  ../200212111616.gBBGG3Q29502@natura.cebas.csic.es/
Also on:    postgresql.org/message-id/200212111616.gBBGG3Q29502@natura.cebas.csic.es

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: andresjavier.garcia@wanadoo.es
  Subject: Re: union query doubt:
  In-Reply-To: <200212111616.gBBGG3Q29502@natura.cebas.csic.es>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox