Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel group by on subquery

return DB::table('candidates AS c')
    ->select( DB::raw('c.name AS c_name,j.name AS j_name,t.questions AS questions, count(g.grade) as countGrade'))
    ->join('job_openings AS j', 'c.fk_id_job_opening', '=','j.id_job_opening')
    ->join('interview_templates AS t', 'j.fk_id_template', '=', 't.id_template')
    ->join('responses AS r', 'r.fk_id_candidate', '=', 'c.id_candidate')
    ->join('grades AS g', 'r.id_response', '=', 'g.fk_id_response')
    ->where('g.fk_id_user',Auth::id())
    ->groupBy('c_name', 'j_name', 'questions')
    ->get();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #group #subquery
ADD COMMENT
Topic
Name
5+3 =