本文介绍了SQL Server 2005查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
select s.part_no,s.part_name,s.uom,i.Invoice_Quantity,r.Return_Quantity,p.Issue_Quantity,sr.Quantity,rp.Return_Quantity,er.Quantity,
((isnull(i.Invoice_Quantity,0)+ isnull(rp.Return_Quantity,0) + isnull(er.Quantity,0)) - (isnull(r.Return_Quantity,0) +isnull(p.Issue_Quantity,0) + isnull(sr.Quantity,0))) as balance
from dbo.dri_Stock as s
left join
(select part_no,sum(Invoice_Quantity) as Invoice_Quantity from dbo.dri_InwardEntry where month(_date)=6 and year(_date)=2012
group by part_no ) as i on s.part_no=i.part_no
left join
(select part_no,sum(Return_Quantity) as Return_Quantity from dbo.dri_ReturnToCustomer where month(date)=6 and year(date)=2012
group by part_no)as r on s.part_no=r.part_no
left join
(select part_no,sum(Issue_Quantity) as Issue_Quantity from dbo.dri_IssueToProd where month(date)=6 and year(date)=2012
group by part_no)as p on s.part_no=p.part_no
left join
(select part_no,sum(Quantity) as Quantity from dbo.dri_ShortReceipt where month(date)=6 and year(date)=2012
group by part_no)as sr on s.part_no=sr.part_no
left join
(select part_no,sum(Return_Quantity) as Return_Quantity from dbo.dri_ReceiptFromProd where month(date)=6 and year(date)=2012
group by part_no)as rp on s.part_no=rp.part_no
left join
(select part_no,sum(Quantity) as Quantity from dbo.dri_ExcessReceipt where month(date)=6 and year(date)=2012
group by part_no )as er on s.part_no=er.part_no
where i.invoice_quantity>0
我想在输出中添加两个coluns,即 Openingbalance和closepingBalance
如何在输出中生成这两个列值
谢谢.
I want add two coluns in the output i.e Openingbalance and closingBalance
how can i generate these two columns values in my output
Thank you.
推荐答案
这篇关于SQL Server 2005查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!