Discussion Locked

Run two differant queries in one table for two differant table

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I want to run some queries which can help me to get result:

I am new for sql

I have two different tables Item and ItemDynamic

In the Item table I have the columns ItemLookUpcode, ItemID and Total Quantity.

In the Item Dynamic table I have the columns ItemID (same as Item table) and Quantity, StoreID.

I want to result as in one table which can give me ItmLookupCode and Quantity (Item.Quantity - ItemDynamic.Qunatity)

I have tried some queries but not worked out please help me.

Thank you in advance.

1 reply

by tony hopkinson

select Item.ItemLookUpCode, Item.TotalQuantity - ItemDynamic.Quantity as Quantity
From Item Left Outer Join ItemDynamic on Item.ItemID = ItemDynamic.ItemID

Assuming you want all ItemIDs in Item whether they have a corresponding entry
in itemdynamic
If you only want those with an itemid in ItemDynamic then change Outer to Inner.

This is a good site to learn stuff at.

http://www.w3schools.com/sql/default.asp

This discussion is closed to new replies.