mardi 2 octobre 2018

Left Joining with two table does not work properly. It shows error for using max function

$student_classtest_for_sba_mark=DB::table('tbl_student_admission') 
                ->leftJoin('tbl_student_subject_mark', 'tbl_student_admission.student_id', '=', 'tbl_student_subject_mark.student_id')
                ->selectRaw('tbl_student_subject_mark.*, tbl_student_admission.student_id,  tbl_student_admission.student_full_name_english, tbl_student_admission.class, tbl_student_admission.section, tbl_student_admission.roll_no, sum(total_obtained_mark) as total_mark, sum(grade_point) as total_gread_point,
                max(if(tbl_student_subject_mark.exam_title = "'.$exam_list[0]->exam_id.'" , total_obtained_mark, null)) E1,                                               
                max(if(tbl_student_subject_mark.result_status = "Fail" , result_status, null)) result_status')                
                ->where('tbl_student_subject_mark.academic_year', $academic_year)
                ->where('tbl_student_admission.class', $class)                
                ->where('tbl_student_admission.section', $section)                
                ->where('tbl_student_subject_mark.subject_name', $subject_name)
                ->groupBy('tbl_student_admission.student_id')
                ->get(); 

Display the Error:

SQLSTATE[42000]: Syntax error or access violation: 1055 'db_smsfinal1user.tbl_student_subject_mark.student_subject_mark_id' isn't in GROUP BY



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire