Re: SELECT counts
| От | Tim Landscheidt |
|---|---|
| Тема | Re: SELECT counts |
| Дата | |
| Msg-id | m3bpa1ulri.fsf@passepartout.tim-landscheidt.de обсуждение исходный текст |
| Ответ на | Select only active entries ("Carel Combrink" <s25291930@tuks.co.za>) |
| Ответы |
Re: SELECT counts
|
| Список | pgsql-novice |
"A. Kretschmer" <andreas.kretschmer@schollglas.com> wrote:
> [...]
> test=*# select foo.status_v, count(myt.status_v) from myt right join (select unnest(array['I','P','X']) as status_v)
fooon foo.status_v=myt.status_v group by foo.status_v;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> status_v | count
> ----------+-------
> X | 0
> I | 1
> P | 2
> (3 rows)
You can also write this as "(VALUES ('I'), ('P'), ('X')) AS
foo (status_v)" which I personally find more readable (con-
stant vs. function).
Tim
В списке pgsql-novice по дате отправления: