Hi,

I'd like to do the following in mysql:

I have a table with field1 and field2. Both fields are not unique. 
Field2 can have the value of 0 or 1.

I'd like to join the results of these two queries:

query 1: select field1, count(field2) as total from table1 group by field1
query 2: select field1, count(field2) as sub from table1 where field2=1 
group by field1

Now I'd like to output the result into 1 set where I get 3 columns:

field1, total, sub.

so it would look something like this:

field1   |   total  |   sub
---------+---------+--------
AAA   |  200     |  93
BBB    | 143      |  22
CCC    | 344      | (NULL)  <- There are NO field2=1 where field1=CCC
DDD   | 287      | 38

etc.

How can I do this?

Thanks,


Danny



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to