473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

purchases - sales problem

4
Hello,

I am working on stock control DB. I have already reached multiple warehouses creation; purchasing; transfer between warehouses.

my problem now is selling item stock deduction. I will show here the query im using

Purchase Query:
Expand|Select|Wrap|Line Numbers
  1. SELECT Warehouse.[Warehouse Code], 
  2.        Warehouse.[Warehouse Description 1], 
  3.        Item.[Item Code], 
  4.        Item.[Item Description 1], 
  5.        Sum([Purchase Item].[Stock Quantity]) + 
  6.            Nz((SELECT SUM(QuantityTransferred) 
  7.                FROM Transfers
  8.                WHERE Transfers.ItemCode = [Item].[Item Code]
  9.                AND Transfers.WarehouseCode = [Warehouse].[Warehouse Code]),0) 
  10.        AS [Stock Quantity], 
  11.        [Purchase Item].[Sum Stock Quantity]
  12. FROM Warehouse 
  13. INNER JOIN ([Purchase Invoice] 
  14. INNER JOIN (Item INNER JOIN [Purchase Item] 
  15. ON Item.[Item Code] = [Purchase Item].[Item Code]) 
  16. ON [Purchase Invoice].[Purchase Number] = [Purchase Item].[Purchase Invoice Code]) 
  17. ON Warehouse.[Warehouse Code] = [Purchase Item].[P Warehouse Code]
  18. GROUP BY Warehouse.[Warehouse Code], 
  19.          Warehouse.[Warehouse Description 1], 
  20.          Item.[Item Code], 
  21.          Item.[Item Description 1], 
  22.          [Purchase Item].[Sum Stock Quantity];
Selling Query:
Expand|Select|Wrap|Line Numbers
  1. SELECT Warehouse.[Warehouse Code], 
  2.        Warehouse.[Warehouse Description 1], 
  3.        Item.[Item Code], 
  4.        Item.[Item Description 1], 
  5.        [Sales Item].[Sales Stock Quantity]
  6. FROM Item 
  7. INNER JOIN (Warehouse 
  8. INNER JOIN ([Sales Invoice] 
  9. INNER JOIN [Sales Item] 
  10. ON [Sales Invoice].[Sales Number] = [Sales Item].[Sales Invoice Code]) 
  11. ON Warehouse.[Warehouse Code] = [Sales Item].[S Warehouse Code]) 
  12. ON Item.[Item Code] = [Sales Item].[Item Code]
  13. GROUP BY Warehouse.[Warehouse Code], 
  14.          Warehouse.[Warehouse Description 1], 
  15.          Item.[Item Code], 
  16.          Item.[Item Description 1], 
  17.          [Sales Item].[Sales Stock Quantity];
The problem is in deduction

I just want Purchases-Sales

please take a look at my db in the following link
(Link removed - please read posting instructions carefully).
Nov 3 '18 #1
4 1341
Luuk
1,047 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.     Item.[Item Code], 
  3.     Item.[Item Description 1], 
  4.     P.PurchasedQuantity - S.SoldQuantity
  5. FROM (purchasesquery) P
  6. OUTER JOIN (salesquery) S ON S.Item.[Item Code] = P.Item.[Item Code]
  7.  
For the fields 'PurchasedQuantity' and 'SoldQuantity' you can/should add aliases to the queries.

In place of 'purchasesquery' you could have the name of a view, which is defined as your query which returns purchases.
Nov 4 '18 #2
gcreed
4
Luuk please check out the db on the following link
Nov 4 '18 #3
Luuk
1,047 Expert 1GB
I do not see a (working) link in your mail.
I do not have MS-Access, so I cannot test anything for you.
Nov 5 '18 #4
twinnyfo
3,653 Expert Mod 2GB
gcreed,

Your DB link has been removed, as it violated site policies. Posters should not simply post their DB to our forum unless specifically asked by a site moderator/expert.

Additionally, you have not offered any true effort in resolving this issue yourself--merely asking others to do the heavy-lifting for you. This is typically not how this forum works. If you would like specific help on a query or data manipulation problem that does not work, we ask you to post the work you have done so far and explain what about it that does not work.

Or, we can offer assistance by providing direction for how you might approach a particular challenge. In your case, what you are seeking to do is find out how many items were purchased and deduct that from the table that holds your current inventory. In theory, that is the solution, but I realize that you want to know how to do that. Most of us will not do this work for you, as we all have jobs that pay the bills, and Bytes is not one of those income producing activities.

I hope you understand.
Nov 5 '18 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: signaturefactory | last post by:
I am trying the following query in and oleDbCommand: SELECT PartLocations.LocationName, Sum(PartsJournal.Quantity) AS SumOfQuantity, PartsJournal.PartsLotNumber FROM PartLocations INNER JOIN...
1
by: Dalan | last post by:
I have attempted to resolve a problem regarding erroneous output using a Between And parameter on several Access 97 queries, but to no avail. The queries are used for report output and...
1
by: Justin | last post by:
We currently have a solution to this coded in VBA in Excel, but the 255 column limitation, general slowness, and instability of Excel are rapidly becoming problems. Access has been suggested as a...
1
by: Malin | last post by:
Hi everybody I have an asp.net application with vb.net codebehind. In the web.config the following settings are set for session state handling: <sessionState mode="InProc"...
3
by: Wired Hosting News | last post by:
Lets say I have 10 products in 10 different stores and every week I get a report from each store telling me how many items they have left for each of the 10 products. So each week I enter in 100...
5
by: Wired Hosting News | last post by:
I tried to be breif and give a scenario so as not to be overlooked because it was soooo long. Let me give you real world. I am a manufacturer of goods and produce 11 items that are distributed...
30
by: HangEveryRepubliKKKan | last post by:
Ahahahaha.. Lets see if I get this Demented Lintard reasoning right. Vista is a failure becuase after 300 days after it's release, it only has 7.5% of the OS market while the Lintard OS, is a...
1
by: Reggraw | last post by:
My program is supposed to output a list of users who input their sales name along with their sales amount and then print out a display. I am using a nested for loop to read through the list of...
6
by: Jabari Powell | last post by:
Okay, so I'm back with another conundrum I hope you all can help me with. I am trying to generate a random number of units sold (for a single sale) that is equal to a randomly generated...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.