Check out example codes for "sql select sum group by id laravel". It will help you in understanding the concepts better.

Code Example 1

   ->selectRaw('sum(no_of_pages) as sum, users_editor_id')

   // originally lists(), which was deprecated in favour of pluck in 5.2
   // and dropped completely in 5.3
   // ->lists('sum','users_editor_id');

// returns array like this:
  users_editor_id => sum,

Learn ReactJs, React Native from