Re: Split the result of a query in 2 rows

Поиск
Список
Период
Сортировка
От Marcos Almeida Azevedo
Тема Re: Split the result of a query in 2 rows
Дата
Msg-id CACL4V1ZgXV3KqyHJ-KD4Q7RFM4reOzJvw8R92P-azimQ2W5rJA@mail.gmail.com
обсуждение исходный текст
Ответ на Split the result of a query in 2 rows  (JORGE MALDONADO <jorgemal1960@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Frank Pinto
Дата:
Сообщение: Re: Split the result of a query in 2 rows
Следующее
От: avpro avpro
Дата:
Сообщение: trigger to access only the last transaction