title: How to find the row associated with the min/max of a column?
body: <p>So basically I have some simple SQL code that looks like the following;</p>
  
  <pre><code>SELECT 
         [Column1]
        ,[Column2]
        ,[Column3]
        ,[Column4]
        ,MIN([Column5]) AS maxColumn5
        ,MAX([Column6]) AS minColumn6
        ,SUM([Column7]) AS sumColumn7
        ,SUM([Column8]) AS sumColumn8
        ,SUM([Column9]) AS sumColumn9
  
  FROM 
      [tableName]
  
  GROUP BY 
          [Column1]
         ,[Column2]
         ,[Column3]
         ,[Column4]
  </code></pre>
  
  <p>What I am trying to do is also find the column either 'Column1', 'Column2', or 'Column3' that corresponds to the MIN([Column6]) and then the column that corresponds to MAX([Column8]).</p>
  
  <p>The output should be exactly the same except there will be an extra 2 column at the end specifying which one the min and max are associated with.</p>