Reputation: 133
I'm trying to re-use a query that was for data ranges for this...basically I'm trying to get information on how many people were invited by the "value". People put this information into their profiles when they sign up and I want to fish it out. I have no idea what I'm doing :).
I'm hoping someone can take a look and tell me what I'm doing wrong, which I understand could be the entire query lol.
The error I get is: #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 'END) as noone, count(CASE WHEN variable
= 'invited' AND 'value' = 'noone'' at line 2.
select
count(CASE WHEN `variable` = `invited` AND `value` = `no one` END) as noone,
count(CASE WHEN `variable` = `invited` AND `value` = `noone` END) as noone,
count(CASE WHEN `variable` = `invited` AND `value` = `bunny` END) as bunny,
count(CASE WHEN `variable` = `invited` AND `value` = `jade` END) as bunny,
count(CASE WHEN `variable` = `invited` AND `value` = `bunnyrabbitsex` END) as bunnyrabbitsex,
count(CASE WHEN `variable` = `invited` AND `value` = `google` END) as google,
count(CASE WHEN `variable` = `invited` AND `value` = `twitter` END) as twitter,
count(CASE WHEN `variable` = `invited` AND `value` = `plurk` END) as plurk,
count(CASE WHEN `variable` = `invited` AND `value` = `facebook` END) as facebook,
count(CASE WHEN `variable` = `invited` AND `value` = `advertisement` END) as advertisement,
from
smf_themes
Upvotes: 1
Views: 103
Reputation: 9724
You need probably something like this :
SELECT
count(CASE WHEN `variable` = `invited` AND `value` = `no one`
THEN 1
ELSE NULL END) as noone,
......
FROM smf_themes
Upvotes: 2
Reputation: 2057
select
value,
count(*)
from
smf_themes
where
variable = 'invited'
group by
value
Upvotes: 3