首先你的A,B表要有关连字段,如ID
select sum(balance) from table a,b
where t.date between B.begin_date and B.end_date and A.ID=B.ID
Group by t.id,t.class