rbragg Posted August 15, 2007 Share Posted August 15, 2007 What do I get a syntax error with this query: <?php $queryCountAll = " SELECT COUNT(call_num) AS callCount, COUNT (CASE WHEN status_num = '1' THEN status_num END) AS closedCount, COUNT (CASE WHEN status_num = '2' THEN status_num END) AS openCount, COUNT (CASE WHEN status_num = '3' THEN status_num END) AS forwardCount, COUNT (CASE WHEN status_num = '4' THEN status_num END) AS followupCount, COUNT (CASE WHEN status_num = '5' THEN status_num END) AS progressCount, FROM call "; $countAllResults = mysql_query($queryCountAll) or die( "Count query failed: " . mysql_error() ); $countAll = mysql_fetch_assoc($countAllResults); ?> Thank you in advance! Link to comment https://forums.phpfreaks.com/topic/65111-solved-multiple-selects-counting-in-a-query/ Share on other sites More sharing options...
rbragg Posted August 15, 2007 Author Share Posted August 15, 2007 Ah, the syntax error goes away when I removed the comma after progressCount. DuH! I will keep from closing this topic for right now until I make sure the query is giving me the right counts. Link to comment https://forums.phpfreaks.com/topic/65111-solved-multiple-selects-counting-in-a-query/#findComment-324950 Share on other sites More sharing options...
rbragg Posted August 15, 2007 Author Share Posted August 15, 2007 Ok, only the 2nd count line successfully counted. ??? Link to comment https://forums.phpfreaks.com/topic/65111-solved-multiple-selects-counting-in-a-query/#findComment-324951 Share on other sites More sharing options...
rbragg Posted August 15, 2007 Author Share Posted August 15, 2007 Ah! I had an extra GROUP BY clause in there. When I omitted it, things work great. Link to comment https://forums.phpfreaks.com/topic/65111-solved-multiple-selects-counting-in-a-query/#findComment-324959 Share on other sites More sharing options...
Orio Posted August 15, 2007 Share Posted August 15, 2007 You sure like talking to yourself... Orio. Link to comment https://forums.phpfreaks.com/topic/65111-solved-multiple-selects-counting-in-a-query/#findComment-324976 Share on other sites More sharing options...
rbragg Posted August 15, 2007 Author Share Posted August 15, 2007 Isn't that a good thing? I talked out a solution and shared it for those who may be searching about the same problem. Thanks for helping. Link to comment https://forums.phpfreaks.com/topic/65111-solved-multiple-selects-counting-in-a-query/#findComment-325032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.