Coba ini:
select m.schoolcode, m.schoolname, sum(e.c1+e.c2+e.c3+e.c4), sum(c.rooms)
from dise2k_enrolment09 e, dise2k_master m ,dise2k_clsbycondition c
where m.schoolcode=e.schoolcode and m.schoolcode=c.schoolcode and e.year='2011-12' and m.year='2011-12' and c.year='2011-12'
and c.classid in(1,2,3,4)
and e.classname = c.classid
group by m.schoolcode, m.schoolname
Cara Anda memilikinya:and e.classname in(1,2,3,4)
seperti memiliki OR
operator di klausa where Anda.
(c.classid=1 or c.classid=2 or c.classid=3 or c.classid=4)
and
(e.classname=1 or e.classname=2 or e.classname=3 or e.classname=4)
Jadi, c.classid bisa jadi "1" dan e.classname bisa jadi "2" yang salah
PERBARUI Saya masih berpikir masalahnya adalah Anda tidak menghubungkan c.classid
dengan e.classname
Cobalah seperti ini:
select m.schoolcode, m.schoolname, sum(e.c1+e.c2+e.c3+e.c4), sum(c.rooms)
from dise2k_enrolment09 e, dise2k_master m ,dise2k_clsbycondition c
where m.schoolcode=e.schoolcode and m.schoolcode=c.schoolcode and e.year='2011-12' and m.year='2011-12' and c.year='2011-12'
and c.classid in(1,2,3,4)
and c.classid = decode(e.classname,1,7,2,7,3,8,4,8,5,9,6,9,7,10,8,10)
group by m.schoolcode, m.schoolname