我有以下表格布局
表一
Teacher Students
Mohan pankaj
Mohan sudeepa
Mohan sujitra
Mohan Sumit
表b(第一学期分数)
Pankaj Maths 50
Pankaj English 40
Pankaj Physics 60
Sudeepa Chemisty 40
Sujitra Physic 10
Sujitra English 40
Sujitra Hindi 70
表c(第2学期分数)
Pankaj Chemistry 50
Pankaj English 40
Pankaj Physics 60
Sudeepa Science 40
Sujitra Physic 10
Sujitra Maths 40
Sujitra Hindi 70
我想要输出为: -
hindi 140.00
maths 40.00
physics 10.00
science 40.00
chemistry 40.00
english 40.00
physics 10.00
我写了查询
select subject,sum(marks) from sample.b where
student in ( select student from sample.a where teacher='mohan')
group by subject
union all
select subject,sum(marks) from sample.c
where student in ( select student from sample.test where teacher='mohan')
group by subject
我得到的结果是
hindi 70.00
maths 40.00
physics 10.00
science 40.00
chemistry 40.00
english 40.00
hindi 70.00
physics 10.00
*问题* Same subjects marks are not adding up
..