Skip to content
Advertisement

addition within sum case when

enter image description here

How to sum all the customers in DS01,02,03 into DS? enter image description here

select sum(case when Ticket=’DS01′ OR ‘DSO2’ OR ‘DS03′ THEN customer ELSE 0 END) AS DS sum(case when Ticket=’MSO2’ OR ‘MS03’ THEN customer ELSE 0 END) AS MS from table group by ticket unsure how to bring in addition condition within “THEN and ELSE ” part

Advertisement

Answer

You can use left():

Or, if you want explicit lists:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement