Spróbuj tego:
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
Tak jak masz:and e.classname in(1,2,3,4)
jest jak posiadanie OR
operatora w klauzuli where.
(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)
Tak więc c.classid może mieć wartość „1”, a e.classname może mieć wartość „2”, co jest błędne
AKTUALIZUJ Nadal uważam, że problem polega na tym, że nie łączysz c.classid
z e.classname
Wypróbuj to tak:
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