是不是把和table3对应的各收费项目名的收费标准插入到table3 ?? insert table3(xuehao,YingJiaoXueFei,YingJiaoZhuSuFei,YingJiaoTiJianFei,YingJiaoBaoXianFei) select t2.xuehao, max(case t2.LeiBieMing when '应交学费' then t1.ShouFeiBiaoZhun else 0 end), max(case t2.LeiBieMing when '应交住宿费' then t1.ShouFeiBiaoZhun else 0 end), max(case t2.LeiBieMing when '应交体检费' then t1.ShouFeiBiaoZhun else 0 end), max(case t2.LeiBieMing when '应交保险费' then t1.ShouFeiBiaoZhun else 0 end) from table2 t2 join table1 t1 on t2.LeiBieMing=t1.LeiBieMing group by t2.XueHao
insert table3(xuehao,YingJiaoXueFei,YingJiaoZhuSuFei,YingJiaoTiJianFei,YingJiaoBaoXianFei)
select t2.xuehao,
max(case t2.LeiBieMing when '应交学费' then t1.ShouFeiBiaoZhun else 0 end),
max(case t2.LeiBieMing when '应交住宿费' then t1.ShouFeiBiaoZhun else 0 end),
max(case t2.LeiBieMing when '应交体检费' then t1.ShouFeiBiaoZhun else 0 end),
max(case t2.LeiBieMing when '应交保险费' then t1.ShouFeiBiaoZhun else 0 end)
from table2 t2 join table1 t1 on t2.LeiBieMing=t1.LeiBieMing
group by t2.XueHao