Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listing detail based on a total and running sum

Status
Not open for further replies.

swiny

Programmer
Joined
Nov 9, 2010
Messages
7

Hi I have the 2 tables below:
TableA
ReceiptNo ItemNumber Quantity
111 A 100
222 A 200
333 A 300
333 B 400
444 A 250
555 B 300
666 A 100
666 B 350
777 A 450

TableB
ItemNumber QuantityTotal
A 900
B 850

I need to list everything in TableA to get the total of A, that comprises of the total in TableB (same with itemB)MeaningI need to list
777 A 450
666 A 100
444 A 250
333 A 100 (not 300)


666 B 350
555 B 300
333 B 200

What would be the easiest way to inquire on it?To creating a running sum?Your feedback is appreciated.Thanks.


 
It's a tricky problem. I believe I solved it once a while ago in MSDN forum, but it will be hard to find the solution.

Check, for a start, the first problem in this blog
CTE and hierarchical queries
although your problem is the opposite.

In the meantime I'll try to find that thread in MSDN forum.

PluralSight Learning Library
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top