title: Multiple Column SUM with Join table - Laravel 5.2
body: <p>I have a two tables <code>winners</code> and <code>check_winners</code>.</p>
  
  <h2>winners:</h2>
  
  <blockquote>
  <pre><code>id     check_winner_id      username     win_number ....
   1                   1           xxx              1
   2                   2           xxx              1
   3                   3           yyy              1
   4                   4           yyy              1
  </code></pre>
  </blockquote>
  
  <h2>check_winners:</h2>
  
  <blockquote>
  <pre><code>id       user_id      chance_of_win....
   1             1                  1
   2             1                  1
   3             2                  1
   4             2                  1
   5             2                  1
   6             2                  1
   7             2                  1
   8             2                  1
  </code></pre>
  </blockquote>
  
  <p>Now i want to <code>join</code> two tables and want to sum <code>chance_of_win</code> column and <code>win_number</code> column group by <code>username</code>. I have tried an way but its not give exactly result for sum of <code>win_number</code>. How can i achieve this?</p>
  
  <pre><code>$winners = DB::table('winners')
              -&gt;groupBy('winners.username')
              -&gt;leftJoin('check_winners', 'winners.id', '=', 'check_winners.user_id')
              -&gt;selectRaw('*, sum(check_winners.chance_of_win) as chance_sum, sum(winners.win_number) as win_sum')         
  dd($winners);
  </code></pre>
  
  <p>with this i get output:</p>
  
  <pre><code>array:2 [▼
    0 =&gt; {#241 ▼
      +"id": 1
      +"check_winner_id": 1
      +"username": "xxx"
      +"chance_sum": "2"
      +"win_sum": "2"
    }
    1 =&gt; {#242 ▼
      +"id": 2
      +"check_winner_id": 2
      +"username": "yyy"
      +"chance_sum": "6"
      +"win_sum": "6"
    }
  ]
  </code></pre>
  
  <p>but <code>win_sum</code> should be <code>2</code> for both <code>array</code>. Where i did wrong? Thanks in advance.</p>