I need product Stock quantity from two tables
I have two tables, how to find stock from both tables? I work on VB.Net, if possible please help me.
Here's the relevant data from the link:
I HAVE TWO TABLES
- product_in (store all product QTY)
- product_out (store all products sold QTY)
first table (PRODUCT_IN) has following values:
Product Code(PK) Description QTY RS121102 SUITS 100 RS129985 SUITS 100 DF-C09 SHIRTS 50 AE-H05 SHIRTS 50
Second table (PRODUCT_OUT) has following values:
Product Code Description QTY RS121102 SUITS 50 AE-H05 SHIRTS 10
I WANT RESULT LIKE BELOW
Product Code Description Total QTY Sold QTY RS121102 SUITS 100 50 RS129985 SUITS 100 0 DF-C09 SHIRTS 100 0 AE-H05 SHIRTS 100 10
The query needed for you request is the following
SELECT a.[Product Code], a.Description, a.QTY as [Total QTY], b.QTY as [Sold QTY] FROM PRODUCT_IN as a LEFT JOIN PRODUCT_OUT as b on a.[Product Code] = b.[Product Code]
By the way, if it is possible remove the spaces between field names. It forces to create unnecessary complicated queries.