多表结合查询请教
这样吗?
SELECT a.* ,
ISNULL(b.YfLxMoeny, 0) AS YfLxMoeny,c.bmName
FROM CkInfo AS a
LEFT JOIN ( SELECT x_KxPzh ,
YfLxMoeny
FROM CkLxInfo
GROUP BY x_KxPzh
) AS b ON a.Pzh = b.x_KxPzh
LEFT JOIN [LOGIN] c ON a.czyName=c.czyName
WHERE a.shenhe = 1 AND c.bmName='业务部'
select t.*,l.*
from (
select a.*,ISNULL(b.YfLxMoeny ,0) AS YfLxMoeny from CkInfo as a left join
(Select x_KxPzh,YfLxMoeny From CkLxInfo Group by x_KxPzh)
as b on a.Pzh=b.x_KxPzh where a.shenhe=1) t left join login l
on t.czyName = l.czyName
Select x_KxPzh,YfLxMoeny
From CkLxInfo
Group by x_KxPzh