Try this: SELECT this, that, theOther, SUM(IF(SUBSTRING(myDate,1,10) >= '20080101' AND SUBSTRING(myDate,1,10) <= '20080131', 1, 0)) AS `January` FROM theTable GROUP BY theOther
Problem was in parentheses Dusan Jay Blanchard napsal(a):
SELECT this, that, theOther, SUM(IF(SUBSTRING(myDate,1,10) >= '20080101' AND SUBSTRING(myDate,1,10) <= '20080131'), 1, 0) AS `January` FROM theTable GROUP BY theOther Throws this error... ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')), 1, 0) AS `January` Can I even do something like this during the SELECT. I tried a BETWEEN and while it did not throw errors it did not give back the expected data...I just got 0
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]