"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