RE: Can I do this in one select sql?
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 tahan [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 true5 tom false 7 tom false 3 sam true3 sam true4 sam false 2 ben true1 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]
RE: Can I do this in a SELECT
no. You can do: SELECT sum(length(Something)) FROM MyDB WHERE MyDB.Something LIKE 'this%' But you will have to specify that for each field you want...then add them all up to get the length. Cal http://www.calevans.com -Original Message- From: Jason Terry [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 25, 2001 2:55 PM To: [EMAIL PROTECTED] Subject: Can I do this in a SELECT I have a need for a SELECT query... I don't really want any of the data from the select... Rather I need the size of the data basically I need SELECT sum(length(*)) FROM MyDB WHERE MyDB.Something LIKE 'this%' - 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 - 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