Re: Split the result of a query in 2 rows - Mailing list pgsql-novice

From Marcos Almeida Azevedo
Subject Re: Split the result of a query in 2 rows
Date
Msg-id CACL4V1ZgXV3KqyHJ-KD4Q7RFM4reOzJvw8R92P-azimQ2W5rJA@mail.gmail.com
Whole thread Raw
In response to Split the result of a query in 2 rows  (JORGE MALDONADO <jorgemal1960@gmail.com>)
List pgsql-novice


On Thu, Mar 5, 2015 at 2:28 AM, JORGE MALDONADO <jorgemal1960@gmail.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

pgsql-novice by date:

Previous
From: Frank Pinto
Date:
Subject: Re: Split the result of a query in 2 rows
Next
From: avpro avpro
Date:
Subject: trigger to access only the last transaction