select student_id, class_id, section_id, exam_date, exam_id,
sum(number*(1-abs(sign(subject-1)))) as sub1,
sum(number*(1-abs(sign(subject-2)))) as sub2,
sum(number*(1-abs(sign(subject-3)))) as sub3,
sum(number*(1-abs(sign(subject-4)))) as sub4,
sum(number*(1-abs(sign(subject-5)))) as sub5,
sum(number*(1-abs(sign(subject-6)))) as sub6
from result
where class_id = '7' and section id = '3' and YEAR(exam_date) = '2012' and exam_id = '3'
GROUP BY student_id
我有一个问题,当我使用 where 子句过滤时,所有数值都为 0,如果我在没有 where 子句的情况下运行查询,结果会很好,但来自所有数据库。如何使用 where 子句过滤查询?谁能帮我?