Здравствуйте, я столкнулся с проблемой.Я стараюсь изо всех сил, чтобы решить эту проблему, но не могу.Я пытаюсь сделать это У меня есть три таблицы, которые показаны на рисунке ниже.Я хочу вывести как последнюю таблицу в данном изображении
И это мой код Laravel ------------------
$academic_year=$request->academic_year;
$class=$request->class_name;
$medium=$request->medium;
$section=$request->section_name;
$exam_name=$request->exam_name;
$subject_list=DB::table('tbl_subject')
->where('class_name', 'LIKE', "%$class%")
->get();
$student_all_subject_mark_search_result=DB::table('tbl_student_subject_mark')
->join('tbl_student_admission', 'tbl_student_subject_mark.student_registration_id', '=', 'tbl_student_admission.student_registration_id')
->select('tbl_student_subject_mark.*', 'tbl_student_admission.student_registration_id', 'tbl_student_admission.student_full_name_english', 'tbl_student_admission.class', 'tbl_student_admission.medium', 'tbl_student_admission.section', 'tbl_student_admission.roll_no',
'max(if(subject_name = "Bangla 1st Paper" , total_obtained_mark, null)) A',
'max(if(subject_name = "Bangla 2nd Paper" , total_obtained_mark, null)) B',
'max(if(subject_name = "English 1st Paper" , total_obtained_mark, null)) C',
'max(if(subject_name = "English 2nd Paper" , total_obtained_mark, null)) D',
'max(if(subject_name = "Mathematics" , total_obtained_mark, null)) E',
'max(if(subject_name = "Religion" , total_obtained_mark, null)) F')
->where('tbl_student_subject_mark.academic_year', $academic_year)
->where('tbl_student_admission.class', $class)
->where('tbl_student_admission.medium', $medium)
->where('tbl_student_admission.section', $section)
->where('tbl_student_subject_mark.exam_title', $exam_name)
->where('tbl_student_admission.student_registration_id is not null')
->groupBy('tbl_student_subject_mark.student_registration_id')
->get();
Но он показывает ошибку
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'max(if(subject_name
= "Bangla 1st Paper" , total_obtained_mark, null)) A' in 'field list' (SQL:
select `tbl_student_subject_mark`.*,
`tbl_student_admission`.`student_registration_id`, ..................