title: Sum multiple columns but one in mysql query
body: <p>Ok, so, I have a product table. Table name is 'orders'. Here are the relevant columns:</p>
  
  <pre><code>orders table: ID, Style, Color, XXS, XS, SM, MD, LG, Other
  </code></pre>
  
  <p>I will be providing a comma separated list of numbers that correspond to values in the ID column (it's the primary key). </p>
  
  <p>Here's the challenge. The columns XXS, XS, SM, MD, LG contain numbers. the Column Other contains text.  Whenever we enter an order, they will enter numbers into those columns, but then a text description of something else into the last column. Here's a few example rows:</p>
  
  <pre><code>Style: 2000, Color: RED. XS: 5, MD: 5, Other: Youth 5-L
  Style: 2000, Color: RED, XS: 3, L: 15
  Style: 2000, Color: RED, Other: Youth 15 XS
  Style: 2000, Color: RED, MD: 10, L:10
  Style: 2000, Color: BLACK, MD: 15, Other: Youth - 10-L
  Style: 2000, Color: BLACK, MD: 20, LG: 25
  </code></pre>
  
  <p>What I need is a query that groups them by Style, Then Color, and sums up each of the columns XXS, XS, SM, MD, and LG (individually), but spits out the text from the other column. I also need this list sorted by Style, and then Color. Lastly, it needs to be a list of rows that are present in a comma separated list of values. Here's the desired output from the table above:</p>
  
  <pre><code>Style: 2000, Color: BLACK. MD: 35, LG: 25
  Style: 2000, Color: BLACK. Other: Youth - 10-L
  Style: 2000, Color: RED. XS: 8, MD: 15, L: 25
  Style: 2000, Color: RED. Other: Youth 5-L
  Style: 2000, Color: RED. Other: Youth 15 XS
  </code></pre>
  
  <p>I hope that makes sense! We need to keep the rows separate because they are entered by Customer, and we need to preserve exactly who ordered what. </p>
  
  <p>BONUS POINTS if the Other column can be concatenated into a string separated by a special unique sequence of chars if it's the same style and color (use |-| as the separator) Example below:</p>
  
  <pre><code>Style: 2000, Color: BLACK. MD: 35, LG: 25, Other: Youth - 10-L&lt;br&gt;
  Style: 2000, Color: RED. XS: 8, MD: 15, L: 25, Youth 5-L|-|Youth 15-XS
  </code></pre>
  
  <h3>EDIT!!!!!</h3>
  
  <p>I think I spoke to soon, and solved it myself. If anyone is curious, here is the query in question. I can't answer this myself for more than a few hours.</p>
  
  <pre><code>SELECT SUM(XXS) as XXS, SUM(XS) as XS, SUM(SM) as SM, SUM(MD) as MD, SUM(LG) as LG GROUP_CONCAT(Other SEPARATOR '|-|') as Other, Style, Color
  FROM orders
  WHERE ID IN(List...)
  GROUP BY Style, Color
  ORDER BY Style, Color;
  </code></pre>
  
  <p>This query groups together all rows based on similar values in Style and Color, sums the columns with numbers in them, and Concatenates together all the columns with text into a format parse-able by my program.</p>