| From: | Marcos Almeida Azevedo <marcos(dot)al(dot)azevedo(at)gmail(dot)com> |
|---|---|
| To: | JORGE MALDONADO <jorgemal1960(at)gmail(dot)com> |
| Cc: | pgsql-novice(at)postgresql(dot)org |
| Subject: | Re: Split the result of a query in 2 rows |
| Date: | 2015-03-05 01:34:24 |
| Message-ID: | CACL4V1ZgXV3KqyHJ-KD4Q7RFM4reOzJvw8R92P-azimQ2W5rJA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
On Thu, Mar 5, 2015 at 2:28 AM, JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
wrote:
> I have a very simple query to a single table as follows:
>
> SELECT field1, field2 FROM tbl_table ORDER BY field1
>
> Is it possible to "split" the results so field1 is displayed in one row
> and field2 in another row?
>
Considering the order by, maybe this will work:
select x as field 1 from
(SELECT field1 as x, field1 as y FROM tbl_table
UNION ALL
SELECT field2 as x, field2 as y FROM tbl_table) as temp
order by y
>
> Best regards,
> Jorge Maldonado
>
--
Marcos | I love PHP, Linux, and Java
<http://javadevnotes.com/java-long-to-string-examples>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | avpro avpro | 2015-03-08 22:01:11 | trigger to access only the last transaction |
| Previous Message | Frank Pinto | 2015-03-04 19:06:41 | Re: Split the result of a query in 2 rows |