Join 2 sum cases

  • Hi Guys,

    Can someone help me with the below.  I need to joins the below two so that I only have one column. I'm struggling how to get there.

    SUM(CASE RepairCodes.[Service] WHEN 'Y' THEN 1 ELSE 0 END) AS SERVICE
    ,SUM(CASE ServCode WHEN 'MST' THEN 1 WHEN 'S&M' THEN 1 ELSE 0 END) AS SERVICE

    I have tried the below but keep getting errors:

    ,SUM(CASE ServCode WHEN 'MST' THEN 1 WHEN 'S&M' THEN 1 WHEN SUM(CASE RepairCodes.[Service] WHEN 'Y' THEN 1 ELSE 0 END AS [SERVICE]
  •  

    ,SUM(CASE WHEN ServCode = 'MST' THEN 1 WHEN ServCode = 'S&M' THEN 1 WHEN RepairCodes.[Service] = 'Y' THEN 1 ELSE 0 END) AS [SERVICE]


    SQL DBA,SQL Server MVP(07, 08, 09) "Money can't buy you happiness." Maybe so, but it can make your unhappiness a LOT more comfortable!

  • Thanks so much

  • You're very welcome.  Thanks for the feedback.

    SQL DBA,SQL Server MVP(07, 08, 09) "Money can't buy you happiness." Maybe so, but it can make your unhappiness a LOT more comfortable!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply