Hi Guys,

This is the error im getting:

#1064 - 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 'FROM leads WHERE ProgramID = '1' AND `TimeStamp` >= '2013-01-01 00:00:00' AND `T' at line 1
This is the query i am using:

Code:
SELECT ProgramName AS `name`, SUM(CASE WHEN Billable = 'PENDING' THEN 1 ELSE 0 END) AS `pending_leads`, SUM(CASE WHEN Billable = 'PASS' THEN 1 ELSE 0 END) AS `pass_leads`, SUM(CASE WHEN Billable = 'FAIL' THEN 1 ELSE 0 END) AS `fail_leads`, FROM leads WHERE ProgramID = '1' AND `TimeStamp` >= '2013-01-01 00:00:00' AND `TimeStamp` < '2013-01-31 23:59:99' GROUP BY ProgramName
I think i know why im getting the error, its because i have the field TimeStamp wrapped in ' ' but if i remove them i still get the same error:

#1064 - 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 'FROM leads WHERE ProgramID = '1' AND TimeStamp >= '2013-01-01 00:00:00' AND Time' at line 1
Can someone help me please resolve my problem.

Thank you.