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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

joining item master to item Location issue

Status
Not open for further replies.

awholtsIT

IS-IT--Management
Aug 18, 2008
27
US
SQL 2005

Table A (Item Master) Table B (Item Location)

There is 1 record for every item in the item master TABLE A.
There are 3 records for every item in the item location table, TABLE B.

I want to join the (2) tables and have the results be just 1 record per item where the quantities in each location from Table B are summed.

ex: Table A.Item = ABC
Table B.Item= ABC, Location 1 has qty of 5
B.Item= ABC Location 2 has qty of 5
B.Item= ABC Location 3 has qty of 1

I want the results to have the following;

Item QTY
ABC 11

My results, no matter what type of join operation I use, has
(3) records. one for each location.

Appreciate any help with this query.

Thanks,

Andrew

 
Code:
Select Items.ItemID, sum(Location.Qty) as TotalQty from Items 
inner join Locations on Items.ItemID = Location.ItemID
group by Items.ItemID
 
That was it.

Many thanks for your help.

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top