Re: [SQL] How to display multiple rows in 1 row

Поиск
Список
Период
Сортировка
От Steve Midgley
Тема Re: [SQL] How to display multiple rows in 1 row
Дата
Msg-id CAJexoSKdVebRKKNXN3TCsyLh9G+o7PyifCUw75o_P0ZrNxyEJA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [SQL] How to display multiple rows in 1 row  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-sql

On Tue, Jan 10, 2017 at 7:40 PM, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Tuesday, January 10, 2017, Steve Midgley <science@misuse.org> wrote:

Given the DDL at the bottom of my email (what I used to test), this sql statement works, I think:

select * from
(select a.id as a_id, * from table_a a
left join table_b b on a.id=b.id) a1
join table_c c on a1.a_id = c.id


Returns

"1.table_c";"1.table_c";1;"";;;"1.table_c";4;3
"2.table_c";"2.table_c";2;"";;;"2.table_c";3;4
"3.table_c";"3.table_c";3;"";;;"3.table_c";2;21


Aside from executing without error I don't see how this works at all. You cannot solve the posed problem by rearranging simple joins.

David J.

Ugh - my bad - I only checked the table_c data in my results and got what I was expecting. I'm out of time tonight to play with this - apologies for bogus response. I'll see if I can rectify tomorrow.

В списке pgsql-sql по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: [SQL] How to display multiple rows in 1 row
Следующее
От: Herwig Goemans
Дата:
Сообщение: [SQL] why is PG NOT pushing where clause to VIEW ? Resulting in bad performance.