TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Devendra Kumar
NA
500
163.1k
Sql query for calculation
May 13 2018 10:04 AM
I have 4 tables
Purchase
Purchase Return
Sale
Sale Return
Data on purchase table
Data on purchase return table
Data on sale table
No data in sales return table
I want the sum of purchase price based on itemcode having same purchase price from all table
where pQty = Qty from purchase table
PRQty = Qty from purchase return table and so on
the calculation for
pQty of Itemcode =1 is 18 (10+8 from purchase table)
PRQty of Itemcode =1 is 3 (2+1 from purchase return table) and so on
-----------------------------------------------------------------------------------------------------------------------------
The final output
The calculation for
closing qty of Itemcode 1 = 21 (sum of pQty- sum of PRQty - sum of SQty - sum of SRQty)
price of ItemCode 1 = 155 (
(sum of _PPrice- sum of _PRPrice - sum of _SPrice - sum of _SRPrice)
same calulation is applied in Itemcode 2
Please help me with the sql query
Reply
Answers (
3
)
1=1 and 2=2 in SQL Server
Reverse the column values