MySQL Sum() multiple columns

前端 未结 7 874
情话喂你
情话喂你 2020-12-05 01:16

I have a table of student scorecard. here is the table,

subject  | mark1 | mark2 | mark3 |......|markn
stud1    | 99    | 87    | 92    |      | 46
stud2            


        
7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 02:20

    //Mysql sum of multiple rows Hi Here is the simple way to do sum of columns

    SELECT sum(IF(day_1 = 1,1,0)+IF(day_3 = 1,1,0)++IF(day_4 = 1,1,0)) from attendence WHERE class_period_id='1' and student_id='1'
    

提交回复
热议问题