title: Case and Sum of Multiple columns
body: <p>In my database I have several thousand customers, with certain criteria happening at different intervals. There are columns for each day of the week (M,Tu,W,Th,F,Sa,Su). I need to see how many days a week that a task will be triggered. I have the query below but it of course also returns the specific day of the week along with the TotalDays per week. However, I need to see just the TotalDays and not additional display each individual day. How can I accomplish this? </p>
  
  <pre><code>SELECT X.*,M+Tu+W+Th+F+Sa+Su AS TotalDays
  FROM
      (
      SELECT
          CASE WHEN [M] = '1' THEN 1 ELSE 0 END as "M",
          CASE WHEN [Tu] = '1' THEN 1 ELSE 0 END as  "Tu",
          CASE WHEN [W] = '1' THEN 1 ELSE 0 END as "W",
          CASE WHEN [Th] = '1' THEN 1 ELSE 0 END as  "Th",
          CASE WHEN [F] = '1' THEN 1 ELSE 0 END as "F",
          CASE WHEN [Sa] = '1' THEN 1 ELSE 0 END as  "Sa",
          CASE WHEN [Su] = '1' THEN 1 ELSE 0 END as "Su"
      FROM
          Customers
      ) X
  </code></pre>
  
  <p>I should say that the data type here is bit so I can't just do a Sum of days such as the following as this returns an error that the data type bit is invalid for sum operator.</p>
  
  <pre><code>SELECT 
   (SUM(M) + SUM(Tu) + SUM(W) + SUM(Th) + SUM(F) + SUM(Sa) + SUM(Su)) as TotalDays
  FROM Customers
  </code></pre>