sql query count function

  • 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!

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • My mistake !! Sorry about that...goggled search "SQL query" and got mixed up with SQL Server !

  • 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

  • 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