February 21, 2012 at 10:24 am
LINKING90 (2/21/2012)
...This is the error I get
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version ...
Check the forum name: It's "SQL Server 2008" one!
February 21, 2012 at 10:24 am
This is a Microsoft SQL Server forum and we assumed, since you're posting on a SQL Server forum, that you are using SQL Server not MySQL. Maybe http://dbforums.com or http:/forums.mysql.com would be a better place to post MySQL questions
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
February 21, 2012 at 10:26 am
My mistake !! Sorry about that...goggled search "SQL query" and got mixed up with SQL Server !
February 21, 2012 at 10:27 am
LINKING90 (2/21/2012)
It's MySQL !!
The syntax will be very similar with a few changes. Try looking at a MySQL forum for examples of case statements.
Jared
CE - Microsoft
February 21, 2012 at 1:07 pm
Thanks all, for your post and comments. Very helpful.
I figured it out / Solution:
select t.topic_key, t.topic_name,
COUNT(CASE WHEN
uel.event_id='1'
and u.intent_id = '2'
THEN u.user_id END) AS numCouldHelp,
COUNT(CASE WHEN
uel.event_id='1'
and u.expertise_id != '1'
THEN u.user_id END) AS numInterested
FROM
topic t
join user_topic u on
t.topic_id = u.topic_id
join user_event_link uel on
u.user_id =uel.user_id
group by t.topic_id
;
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply