473,621 Members | 2,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Subtract records from two different tables

1 New Member
I have the following tables, with their fields.
TblSales
Saleid As auto Number
Saledate As Date
Item As Text
Brand As text
Quantity As Number
Unticost As currency
Totalcost As currency
Stockid As text

TblStock
Stockid As Text
StockName As Text
Brand As Text
Totalstock As Number
Stockremain As Number

How can I subtract sales Quantity from the Totalstock for every transaction

Am having too many logical errors Please someone help me

Thanks in advance
Jul 14 '22 #1
1 5641
NeoPa
32,566 Recognized Expert Moderator MVP
This seems to be a strange question.

Fomson:
How can I subtract sales Quantity from the Totalstock for every transaction?
It's almost like you think it makes any sense to do so in a report (or SELECT query). How could it? The [Totalstock] value would be the same for each associated transaction. Consider that you might have a number of items in stock starting at 100 then twenty different transactions of four each (adding up to eighty). Any such report would show ninety-six for each line.

No. You have to be clear about what each value means. Is it stock as at some time in the past? Is it ever updated? Which of the transaction items have already been applied to the stock levels so should not be counted again?

It actually is possible to get a reported value of stock items left using the original value and subtracting all relevant transactions, but as we've seen, this is not simple or straightforward . In practical terms most systems are designed so it is not required to process through all historical transactions (+ve & -ve) in order to determine the current status.
Fomson:
Am having too many logical errors Please someone help me
We can only really do that properly if/when you share with us some details of what you're trying to do and exactly what you're getting stuck on.
Jul 15 '22 #2

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

Similar topics

4
2362
by: manning_news | last post by:
Using SQL2000. How do I format my select statement to choose one out of 24 different tables? Each table is slightly different and I was hoping I could use one select statement and format it on-the-fly instead of using 24 different ones. I had in mind using a case statement, something like this: select * from case when <input parameter> = 'something1' then tblSomething1 case when <input parameter> = 'something2' then tblSomething2...
7
2093
by: Paolo | last post by:
I know I should not be doing this, but I find it very useful. I have a database in Access which stores data for a small company. Sometimes we need to add similar information to different tables. Currently I am already doing something similar by copying certain records into the same table. The only thing that changes is one field. Please look at the code: Dim MyDb As DAO.Database, MyRs As DAO.Recordset Dim strCode As String
10
15353
by: Marizel | last post by:
I'm not sure there's an easy solution to this, but thought I'd ask. I often find myself with a query which I'd like to reuse, but with a different datasource. These datasources generally have identical field names. The queries select a subset of the fields, so "Select *" is not really an option. Is there an easy way to change the source of a query, either in the design grid or SQL display? I suppose I could copy the SQL into WordPad...
20
2101
by: Dennis Gearon | last post by:
I am working on a design where a location for something can have: Fully qualified address with even building names, room numbers, and booth numbers. **-OR-** GPS location **-OR-** Both Other than triggers, is there a way to enforce this using tables and
0
1186
by: apgoh | last post by:
Our system is on AIX5.3 ML5, DB2 v8.2 FP11, and we are running C applications. There are 2 scheduled cronjobs, which are actually triggering the same binary, but passing in different parameter. With different parameters given, these 2 jobs are meant to do delete unused records from 2 different tables (there's no relationship between these 2 tables). The scenerio is when the first job is still running (it takes longer when there are more...
2
1185
by: lieufirst | last post by:
hi there, well i have a db that is consists of 6 tables. 1 for the detailed information of students, 1 for the exams they should take another table that combine student name and class and id from information of student table with the exam code from exams table and his grade in this exam . at the last table i choosed for the field of the name a lookup wizard that connects to student detailed information table so i dont have to type the...
6
3200
HaLo2FrEeEk
by: HaLo2FrEeEk | last post by:
I have two different tables which havea different number of columns. One of the tables gets a new row every day and is populated with a st of 4 IDs from another table, along with today's date and an expiration date. The other table also has today's date and an expiration date, but it only gets one ID from the other table, and it is updated once a week. I need to get the most recent column from both of these tables, and I'd like to do it in...
14
20473
by: PreethiGowri | last post by:
I want to subtract 2 column of two different tables and update in one of the table say, i have two tables 'main' and 'sub' both tables have a column named 'quantity' so i have to do it in this way: update main set quantity = ((quantity of main) - (quantity of sub)) where name = pens; Somebody help me please.
0
8213
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8156
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8653
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8597
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8306
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2587
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1460
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.