Zkuste toto:
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
Jak to máte:and e.classname in(1,2,3,4)
je jako mít OR
operátor ve vaší 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že c.classid může být "1" a e.classname může být "2", což je špatně
AKTUALIZACE Stále si myslím, že problém je v tom, že nepřipojíte c.classid
s e.classname
Zkuste to takto:
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