这个语句可以实现:
select sum(a.result) from test_cj2 A where (400< (select sum(b.result) AS BB from
test_cj2 B where B.p_id=A.p_id and B.test_id=A.test_id and lclass=1 )) and test_id=12 and lclass=1 group by p_id
order by sum(result);
但是太慢了,表中有记录18000条时,用了45秒才出来,还有更好的方法吗?
select sum(a.result) from test_cj2 A where (400< (select sum(b.result) AS BB from
test_cj2 B where B.p_id=A.p_id and B.test_id=A.test_id and lclass=1 )) and test_id=12 and lclass=1 group by p_id
order by sum(result);
但是太慢了,表中有记录18000条时,用了45秒才出来,还有更好的方法吗?
(select sum(result) as cj from test_cj2 where test_id=12 and lclass_id=1 group by p_id)
where cj>400