hello i got the following code that produces a sum correctly done, but whenever i try to join the table to another to concat some results in the same dashboard it douobles up the values.
$data = Reparacoes::select(DB::raw("SUM(valor) as sum, matricula"))
->orderBy("matricula")
->groupBy(DB::raw("matricula"))
->get();
return view('page', ['data' => $data]);
if i add this to the code as follows it doubles up the values:
$data = Reparacoes::select(DB::raw("SUM(valor) as sum, matricula"))
->join('formulario', 'reparacoes.matricula', '=', 'formulario.matricula')
->orderBy("matricula")
->groupBy(DB::raw("matricula"))
->get();
how to i produce the same sum as in the first statement but with the join? so i can fetch more results and query as i wish