次のテーブルレイアウトがあります
表 a
Teacher Students
Mohan pankaj
Mohan sudeepa
Mohan sujitra
Mohan Sumit
表b(1学期の点数)
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
..