SQL2008中T-SQL语句,创建视图的问题

2025-01-04 05:44:52
推荐回答(1个)
回答1:

试试

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