Hi guys, I tried looking up other threads in this forum for some problem similar to mine, but no luck.
I'm trying to build a query that could calculate the # of available products in stock. It seems simple when you think of it, but I couldn't get the results that I needed and couldn't figure out what I'm doing wrong. ;(
I have a table that lists all the products, where the product code is the primary key, and on that table, there is a column that states how many units of that product are there in total (UnitsTotal).
I also have another table that has records of transactions involving the sale of those products.
Columns that I want to see on the query are:
ProductID || ProductName || UnitsTotal || QtySold || UnitsAvailable
- ProductID, ProductName, UnitsTotal: I want every possible product listed (one entry for each product on one row) << values can be obtained from the 'ProductListing' Table
- QtySold: I want this column to be a count of products sold, and '0' values are allowed.
- UnitsAvailble: This will be a calculation of the difference between 'UnitsTotal' and 'QtySold' for each product.
Also, I know restocking of products is another issue (affects 'UnitsTotal'), but I don't want to include that into this query yet.
I've been working on this for hours and the query only returns information involving products that have been sold, but the records the products that have yet to be sold are omitted. ;(
Any help would be appreciated. Thanks in advance!
I'm trying to build a query that could calculate the # of available products in stock. It seems simple when you think of it, but I couldn't get the results that I needed and couldn't figure out what I'm doing wrong. ;(
I have a table that lists all the products, where the product code is the primary key, and on that table, there is a column that states how many units of that product are there in total (UnitsTotal).
I also have another table that has records of transactions involving the sale of those products.
Columns that I want to see on the query are:
ProductID || ProductName || UnitsTotal || QtySold || UnitsAvailable
- ProductID, ProductName, UnitsTotal: I want every possible product listed (one entry for each product on one row) << values can be obtained from the 'ProductListing' Table
- QtySold: I want this column to be a count of products sold, and '0' values are allowed.
- UnitsAvailble: This will be a calculation of the difference between 'UnitsTotal' and 'QtySold' for each product.
Also, I know restocking of products is another issue (affects 'UnitsTotal'), but I don't want to include that into this query yet.
I've been working on this for hours and the query only returns information involving products that have been sold, but the records the products that have yet to be sold are omitted. ;(
Any help would be appreciated. Thanks in advance!