this should work:

select NAME, sum(if(IF_PURCHASED='true',COUNT,0)),
sum(if(IF_PURCHASED='false', COUNT,0)) from TABLENAME group by NAME;

eva


-----Original Message-----
From: cengiz "taţhan [mailto:[EMAIL PROTECTED]
Sent: Friday, October 24, 2003 9:29 AM
To: [EMAIL PROTECTED]
Subject: Can I do this in one select sql?


Hi everybody;

  I have a table like this;

|| NAME || IF_PURCHASED || COUNT  ||
---------------------------------------  
   tom     true            5
   tom     false           7
   tom     false           3
   sam     true            3
   sam     true            4
   sam     false           2
   ben     true            1
----------------------------------------

i want to a select querry that can do this;

|| NAME  || TRUE_TOTAL_COUNT || FALSE_TOTAL_COUNT ||
---------------------------------------------------- 
   tom      5                   10
   sam      7                   2
   ben      1                   
----------------------------------------------------

I did this with 2 temporary  tables. one of selects  
true total count , other selects false total counts
then I JOINed them with UNION

Can I do this in one select sql?


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to