cteera
cteera

Reputation: 67

what is wrong with this mysql statement

#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 ) AS county FROM q_mem_tim at line 2

SELECT Count( *  ) AS m, 
       SUM(CASE 
             WHEN y = '2011' THEN 1
             ELSE 0 ) AS county
  FROM q_mem_tim

What is wrong with my code?

Upvotes: 0

Views: 66

Answers (1)

OMG Ponies
OMG Ponies

Reputation: 332771

Use:

SELECT COUNT(*) AS m, 
       SUM(CASE 
             WHEN y = '2011' THEN 1
             ELSE 0 
           END) AS county
  FROM q_mem_tim

A CASE statement requires the END keyword to indicate when it ends.

Upvotes: 5

Related Questions