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
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)