Вот мой запрос
CREATE VIEW marksheet as
SELECT name as name, student_id as student_id,
roll as roll, class as class,exam_year as exam_year,
subject_name as subject, exam_type as exam_type,
sum(full_mark) as full_mark, sum(getmark) as getmark,
department as department,
IF(SUM(IF(gpa='f' OR gpa='F',-9999,gpa))>=0,
CAST(IF(subject_type=1,SUM(gpa)-2/count(subject_name),SUM(gpa)/count(subject_name))
AS CHAR), 'F') as total_gpa
FROM mark
GROUP by roll, class, exam_type
Не работает
IF(subject_type=1,SUM(gpa)-2/count(subject_name),SUM(gpa)/count(subject_name))
Каждый раз, когда работают только else
Состояние SUM(gpa)/count(subject_name
Не работает subject_type=1,SUM(gpa)-2/count(subject_name)
Мой стол
Результат: gpa = 5 + 8 + 4 + 6
= 23
Но subject_type = 1 so ,minus -2
(не работает)
= 21 (Not work)
Окончательный Gpa = 21 / количество (имя_субъекта)