select *
from #temptable as A where t_salary<(select AVG(t_salary) from #temptable as B where A.d_no = B.d_no )
这样看你应该好理解一些,这是多表查询,俩表的链接是都有列(no);求的是表a中t_salary<表b中t_salary平均值的所有项
select *
from #temptable as A where t_salary<(select AVG(t_salary) from #temptable as B where A.d_no = B.d_no )
这样看你应该好理解一些,这是多表查询,俩表的链接是都有列(no);求的是表a中t_salary<表b中t_salary平均值的所有项