注册 登录
编程论坛 SQL Server论坛

这个语句 麻烦给详解 下,是怎么实现的

某小多 发布于 2014-07-21 15:02, 471 次点击
select * from #temptable as A where t_salary<(select AVG(t_salary) from #temptable as B
where A.d_no = B.d_no )

[ 本帖最后由 某小多 于 2014-7-21 15:05 编辑 ]
3 回复
#2
小岑2014-07-21 16:18
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平均值的所有项
#3
tlliqi2014-07-21 16:20
分解开看看
#4
tlliqi2014-07-21 16:21
以下是引用小岑在2014-7-21 16:18:27的发言:

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平均值的所有项
对的
1