title: Grouping by line items in mysql
body: <p>i need the result of one column to be different on each row.  </p>
  
  <p>This is how the data appears:</p>
  
  <pre><code>Ticketnumber  Legnumber  Commission
  100           1          50
  100           2          50
  </code></pre>
  
  <p>This is how I need it to appear:</p>
  
  <pre><code>Ticketnumber  Legnumber  Commission
  100           1          100
  100           2          0
  </code></pre>
  
  <p>So when the legnumber = 1 I need the commission to group by ticketnumber, but when the legnumber > 1 the commission should be zero. I tried writing a case statement to no avail.  Any suggestions on how to accomplish this? </p>