Re: combination join against multiple tables

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: combination join against multiple tables
Дата
Msg-id CAKFQuwbp356YLQOESo0Ygc6y0=EU0XOk=TiMt+NUoE7UFdvZ5g@mail.gmail.com
обсуждение исходный текст
Ответ на combination join against multiple tables  (Geoff Winkless <pgsqladmin@geoff.dj>)
Ответы Re: combination join against multiple tables
Список pgsql-general
On Friday, January 31, 2020, Geoff Winkless <pgsqladmin@geoff.dj> wrote:
Now the problem is that I would like to return all the rows from a, but with a single row where t2.b and t1.b match.

So, the final,number of rows for each “a” is the larger row count of “b” and “c” having the same “a”.  Furthermore for the first “n” rows “b” and “c” should be paired together by position.  The smaller count column just gets nulls for the extra rows.

Probably the easiest way is to combine the matches for “b” and “c” into arrays the jointly unnest those arrays in the final result - with in the select list or maybe as part,of a lateral join, not sure without experimentation.

Otherwise you can add “row_number” to “b” and “c” and then left join on (a, row_number).

David J.

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

Предыдущее
От: Geoff Winkless
Дата:
Сообщение: combination join against multiple tables
Следующее
От: Geoff Winkless
Дата:
Сообщение: Re: combination join against multiple tables