How to write a crosstab which returns empty row results

Поиск
Список
Период
Сортировка
От David Goldsmith
Тема How to write a crosstab which returns empty row results
Дата
Msg-id CAFtPsZqfiRvRp1EngwEfyNMu=nW11C0i7WvtYtBpO0gjjwLPwQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: How to write a crosstab which returns empty row results  (Brad White <b55white@gmail.com>)
Список pgsql-general
Hi. New subscriber and intermediate level SQL writer here, still pretty new to Postgresql (but I don't know how to do the following in TSQL either).

I've figured out how to write a crosstab query I need; the problem is that the number of row results should be 72, but I'm only getting 41.  I'm pretty sure this is because there actually isn't any data matching my where constraints for the 31 missing row header values, but I nevertheless need them in my result, with NULLs where there is no data.  How do I force "empty rows" to be included in my query output? (I've tried LEFT JOINing to the row header results, and using CASE statements; but due to my unfamiliarity w/ using crosstab, I'm not sure if I've used those correctly in the current context; so if using either or both of those is part of the solution, please do more than simply saying "use a Left join" or "use a case statement," i.e., furnish an example, please.

Thanks!

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

Предыдущее
От: Brad White
Дата:
Сообщение: Re: Implementing foreign data wrappers and avoiding n+1 querying
Следующее
От: Brad White
Дата:
Сообщение: Re: How to write a crosstab which returns empty row results