Subscribe to Subscribers
Talk to Webmaster Tony John

Online Members

s
More...

Forums » .NET » SQL Server »

Sql server 2005 query


Posted Date: 06 Jul 2012      Posted By:: salmanc     Member Level: Bronze    Member Rank: 3172     Points: 5   Responses: 1



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


i want add two columns in output one for openingBalance and second is closingBalance
how can i generate these columns in output to show openingbalance and Closing Balance
Thank you.
Thank you




Responses

#679242    Author: prema      Member Level: Bronze      Member Rank: 3832     Date: 06/Jul/2012   Rating: 2 out of 52 out of 5     Points: 0

I think it can helps you,
http://www.vbforums.com/showthread.php?t=598727



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : SQL REquired splition in home address
Previous : Medical shop code-- sql server 2000 purchase and sales using sum
Return to Discussion Forum
Post New Message
Category:

Related Messages
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2012 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.