I have table like this
here my controller but it sum all score from score1 + all score 2 + all score 3
$data = DB::table('group_table')
->select('team','level',DB::raw('sum(score1 + score2 + score3) as total'))
->groupBy('team','level')
->get();
return response()->json($data);
i want only sum top 3 score from score 1, score 2, and score 3. as en example in Team STARS Level 1 from your DB total will be 646 because:
TOTAL = [(Top 3 Score 1) + (Top 3 Score 2) + (Top 3 In Score 3)]
TOTAL = [(89 + 81 + 66) + (80 + 73 + 71) + (72 + 64 + 50)]
i dont know how to take only top 3 score on each score 1, score 2, and score 3. can someone help me
