使视图表在条件允许时创建使用

时间:2018-11-09 03:46:04

标签: php mysql codeigniter mysqli

我正在使用codeigniter。如果我发现1个主题=失败,我想这样喊 然后所有结果= f / fail。我怎么写查询。我使用group by是因为1个学生有很多班级数据。

我的桌子

enter image description here如何编写此查询。我想如果一个或多个科目不及格,就等于f。  然后像这样getMark = f或getMark = 4.40。

查询

CREATE VIEW result as SELECT name as name,roll as roll,class as 
 class,subject_name as subject,exam_type as exam_type,sum(full_mark) as 
full_mark,sum(getmark) as getmark, if(gpa =='f', 'F',sum(gpa)) as 
total_gpa FROM mark GROUP by roll,class,exam_type

0 个答案:

没有答案