From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: SELECT counts |
Date: | 2010-07-21 11:27:05 |
Message-ID: | 20100721112705.GE20566@a-kretschmer.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
In response to Tim Landscheidt :
> "A. Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Raveen Vedarshana | 2010-07-21 12:06:09 | Re: C Postgresql CGI |
Previous Message | Tim Landscheidt | 2010-07-21 11:17:37 | Re: SELECT counts |