搜索

SQL Server数据库多表关联汇总查询的问题解决

发表于 2025-11-05 13:05:18 来源:益强智未来
SQL Server数据库多表关联汇总查询的问题解决
复制select isnull(s.mnumber,据库决ss.mnumber) mnumber,isnull(m.whcode,ss.whcode) whcode,       isnull(sum(factreceiptquan),0)-isnull(sum(factissuequan),0) + sum(isnull(ss.quan,0)) quan        from (select * from gy_inoutmain where billcode in(1201,1202,1203,1204,1205,1206) ) m       inner join gy_inoutsub s on m.inoutmainid=s.inoutmainid       left join(           select sms.mnumber,sm.whcode,sum(sms.quan) quan from Kf_StartMain sm           inner join Kf_Startsub sms on sm.startmainid=sms.startmainid           group by sm.whcode,sms.mnumber       ) ss on m.whcode=ss.whcode and s.mnumber=ss.mnumber       group by isnull(m.whcode,ss.whcode),isnull(s.mnumber,ss.mnumber) order by s.mnumber  1.2.3.4.5.6.7.8.9.10.
随机为您推荐
版权声明:本站资源均来自互联网,如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

Copyright © 2016 Powered by SQL Server数据库多表关联汇总查询的问题解决,益强智未来  滇ICP备2023006006号-17sitemap

回顶部