2
What am I doing wrong in this queryRaw? The goal is to display the summed values if ID = ID, but I’m getting the total sum of the column.
Excerpt from *query made on Controller:
//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);
}
Test by placing a single quotation mark on the url or input if it is the case of the search). Use, say, 100% in the Laravel way. Use thus ->whereRaw('tbl_resposta_super.pesquisa_id = ?' , [$search->id])
– Marcos Xavier