Login
Register
Tutorials
Forum
Career Development
Resources
Reviews
Jobs
Interview
Communities
Projects
Training
Silverlight Games
|
Bookmarks
|
New Members FAQ
|
Mentor
|
Code Converter
|
IT Companies
|
Peer Appraisal
|
Members
|
Revenue Sharing
|
Computer Jokes
|
New Posts
|
Social
|
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
Tweet
Responses
#679242 Author:
prema
Member Level:
Bronze
Member Rank:
3832
Date: 06/Jul/2012 Rating:
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
.
Tweet
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
Exporting SQL Server Table to Excel Using DTS
Function is not working
trigger problem.
DATE SEARCH IN ASPX PAGE
Any body tell good pl sql book reference URL and FAQ
Active Members
Today
Jivani
(23)
naveensanagase...
(21)
Asheej T K
(20)
Last 7 Days
baskar
(303)
Ultimaterengan
(267)
Rakesh Chaubey
(184)
more...
Awards & Gifts
Email subscription
.NET Jobs
.NET Articles
.NET Forums
Articles Rss Feeds
Forum Rss Feeds