title: How do I add an extra column to the results of a GROUP BY with a value that matches a condition?
body: <p>I'm trying to use GROUP BY to generate a summary of a table, but I want to add a column with a value that matches a condition from the original table.  The condition I want to check for is that style = 2 so that a new column with the filename that matches that style is shown in the results.</p>
  
  <p>This is what the original table looks like:</p>
  
  <pre><code>category  |  value | style | filename
     A      |   8    |   0   |   AAA    
     B      |   4    |   2   |   BBB    
     B      |   6    |   1   |   CCC    
     A      |   3    |   2   |   DDD    
     A      |   6    |   1   |   EEE    
     C      |   7    |   2   |   FFF   
     B      |   5    |   1   |   GGG    
     A      |   3    |   1   |   HHH    
  </code></pre>
  
  <p>This is what I want:</p>
  
  <pre><code>category  |  total_value   | filename
     A      |        20      |   DDD
     B      |        15      |   BBB
     C      |         7      |   FFF
  </code></pre>
  
  <p>I tried this query, but the filename chosen was the MINIMUM, not the one that matches style = 2:</p>
  
  <pre><code>SELECT category, SUM(value) AS total_value, MIN(filename) AS filename FROM data GROUP BY category;
  </code></pre>