Re: SELECT counts
От | A. Kretschmer |
---|---|
Тема | Re: SELECT counts |
Дата | |
Msg-id | 20100721112705.GE20566@a-kretschmer.de обсуждение исходный текст |
Ответ на | Re: SELECT counts (Tim Landscheidt <tim@tim-landscheidt.de>) |
Список | pgsql-novice |
In response to Tim Landscheidt : > "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)foo on 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). You are right, thx. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 389D 1DC2 3172 0C99
В списке pgsql-novice по дате отправления: