From: | javier garcia <andresjavier(dot)garcia(at)wanadoo(dot)es> |
---|---|
To: | "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | union query doubt: |
Date: | 2002-12-11 16:21:43 |
Message-ID: | 200212111616.gBBGG3Q29502@natura.cebas.csic.es |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Frank Bax | 2002-12-11 16:39:14 | Re: union query doubt: |
Previous Message | Frank Bax | 2002-12-11 15:57:37 | Re: Backup to data base how ? |