What am I doing wrong in this queryRaw ? The goal is to display the sum values if ID = ID, but I'm getting the total sum of the column.
Excerpt from the Controller query:
//Show
public function show( Pesquisa $pesquisa )
{
$this->guardaAvaliacao( $pesquisa );
$pesquisa->load( [
'respostas' => function ( $relation ) {
$relation->with( [ 'pergunta.opcoes', 'opcao' ] );
}
] );
$nota = DB::table('clima.tbl_resposta_super')
->selectRaw('sum(nota_original) as nota_original ')
->whereRaw('tbl_resposta_super.pesquisa_id', '=' .$pesquisa->id)
->groupBy('nota_original')
->get();
dd($nota);
}