| From: | Jeff Lanzarotta <delux256-postgresql(at)yahoo(dot)com> |
|---|---|
| To: | PostgreSQL GENERAL List <pgsql-general(at)postgresql(dot)org> |
| Subject: | Question about a query with two count fields |
| Date: | 2007-09-11 15:50:47 |
| Message-ID: | 544403.95240.qm@web36804.mail.mud.yahoo.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hello,
I am in need of producing a query that has two count fields in it... Something like:
select to_char(ts, 'MM/DD/YYYY') as "day", str, proc,
(select count (*) as good from foobar where z != 0),
(select count (*) as bad from foobar where z = 0)
from foobar
where str != 99999
group by str, day, proc order by str
From this query, the output should look something like this:
day | str | proc | good | bad
09/10/2007 | 1 | xyz | 1 | 3
09/10/2007 | 1 | abc | 3 | 2
09/10/2007 | 2 | xyz | 3 | 5
09/10/2007 | 2 | abc | 1 | 2
I hope I have explained the situation...
I appreciate the help...
Thanks.
-Jeff
| From | Date | Subject | |
|---|---|---|---|
| Next Message | George Pavlov | 2007-09-11 15:55:53 | Re: Question about a query with two count fields |
| Previous Message | Alban Hertroys | 2007-09-11 15:50:38 | avg() of array values |