试试
create view v_teacher
as
select a.tname,a.tsalary,b.avg_tsalary,c.avg_didtsalary,a.tsalary-c.avg_didtsalary sal
from 表 a,
(select avg(tsalary) avg_tsalary from 表) b
(select did,avg(tsalary) avg_didtsalary from 表 group by did) c
where a.did=c.did
你把表都换成A