22,209
社区成员
发帖
与我相关
我的任务
分享
select a.*,b.*,c.*
from #a a
full join #b b on a.PlateNumber=b.PlateNumber and a.PeccancyTime=b.PeccancyTime
full join #c c on a.PlateNumber=c.PlateNumber and a.PeccancyTime=c.PeccancyTime
select * from 入库表 a
full join (领料表 b
full join 退料表 c on a.日期=c.日期 and a.料号=c.料号
)on a.日期=b.日期 and a.料号=b.料号
select a.*,b.*,c.*
from #a a
full outer join #b b on a.PlateNumber=b.PlateNumber and a.PeccancyTime=b.PeccancyTime
full outer join #c c on (a.PlateNumber=c.PlateNumber and a.PeccancyTime=c.PeccancyTime)
or (c.PlateNumber=b.PlateNumber and c.PeccancyTime=b.PeccancyTime)
今天突发奇想 这么写。试了几种情况。还可以。下午继续测试。如果没问题 就结贴了SELECT aa.*,cc.* FROM
(SELECT COALESCE(a.PlateNumber,b.PlateNumber) PlateNumber,COALESCE(a.PeccancyTime,b.PeccancyTime) PeccancyTime,... FROM #a a
FULL JOIN #b b ON a.PlateNumber=b.PlateNumber AND a.PeccancyTime=b.PeccancyTime) aa
FULL JOIN #c cc
ON aa.PlateNumber=cc.PlateNumber AND aa.PeccancyTime=cc.PeccancyTime