473,385 Members | 1,769 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,385 software developers and data experts.

Updating values in Table1 based on date condition from Table2

I have two tables, one with tasks and the other with some relative data as below:
Expand|Select|Wrap|Line Numbers
  1. Task             Client    Date         Hummer qty
  2. Made something a   X1   01.02.2022
  3. Made something b   X2   05.02.2022
  4. Made something c   X3   05.02.2022
  5. Made something d   X2   07.02.2022
So this one represents daily activity for different clients. I need to fill "Hummer qty" column for every day entered for every Client using second table below where there is Dated history of each Client, at which dates quantity of hummers were increased by each Client.
Expand|Select|Wrap|Line Numbers
  1. Client  Date     Hummer qty
  2. X1    15.03.2021    1
  3. X1    23.05.2021    3
  4. X2    08.02.2019    1
  5. X2    06.02.2022    2
  6. X2    06.03.2022    3
  7. X3    16.03.2022    1
as a result, first table should be as below:
Expand|Select|Wrap|Line Numbers
  1. Task             Client   Date     Hummer qty
  2. Made something a   X1    01.02.2022    3
  3. Made something b   X2    05.02.2022    1
  4. Made something c   X3    05.02.2022    0
  5. Made something d   X2    07.02.2022    2
in this case tried to use Dlookup with conditions where daily dates >= to history dates + Clients are identical between tables. But it does not work (empty). Simple query returns only first found quantities in history and set it to all the rows of respective client.
Dec 15 '22 #1
2 6987
NeoPa
32,556 Expert Mod 16PB
Hi Oleksandr.

Welcome to Bytes.com :-)

Oleksandr:
I need to fill "Hummer qty" column for every day entered for every Client using second table below where there is Dated history of each Client, at which dates quantity of hummers were increased by each Client.
Are you sure? Is this your idea or was it suggested to you?

That approach goes against the doctrine of normalisation (Database Normalisation and Table Structures) of data and, while there are cases where the practicalities override the requirements of managing data in a logical way, I would advise against this unless the reasons for doing so are very solid & impelling.

Normally, when presented with a requirement to show totals against any group headings, it is done with a query where the grouping is matched between the tables and the quantity values are aggregated (in this case summed together to reach a total). There is no requirement to store these calculated values. Logically they can change over time - thus leaving the updated records in your approach unreliable anyway.

In your example data it isn't clear what your actual grouping is. At one point it looks like just the Client and the Date, yet at another it seems to include the Client, the Date and the Task. As far as explaining the situation generally is concerned, this doesn't matter. I have explained the issues that work whatever is the actual case for you. However, if you continue to work with this without a clear understanding yourself of what fits where, then you will struggle massively.

Best of luck with your project.
Dec 16 '22 #2
XPS35
4 Nibble
You also asked the same question on another forum (Link removed) . Crossposting without mentioning it is not appreciated. There too you got the answer that you are breaking the rules of good database design by wanting this.
Dec 16 '22 #3

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

Similar topics

3
by: Nicolae Fieraru | last post by:
Hi All, I have a select query which is based on tblOne and tblTwo. The query selects some of the records in tblOne and tblTwo, based on a Where condition. What I need to do is to change the...
4
by: Michael | last post by:
Hello NG i use Microsoft SQL server and my problem is how i can select table1 into the dataset and insert this datas into table2 (backup table). Has someone a idea or a code example? Thanks
1
by: wdw1970 | last post by:
Hello Everyone! This is my first post to the forum. --------------------------------------------------------------------------------------------- In my database, I have a continuous...
7
by: J-P-W | last post by:
Hi, in the past I've spent ages writing VB routines to get around this problem, is there a simple way? I have three tables for a membership system: tblMembership - MembershipNumber; Names etc...
1
by: Pathik | last post by:
Hi All, I have to get the values of "reading" and "value" elements of context Person/Category/Group/ser.These values must be on condition based,means I have to get the values of "reading" and...
0
by: Hetal | last post by:
Hi.. I am working on VB.NET 2003 (windows form) application and using ADO.NET to deal with databases. The table structure i am working with is as follows. DB1.Table1 (source)...
1
by: psyvanz | last post by:
i have created 2 tables name table1 and table2 with the same fieldnames in subjectnumber(sub-0001), subjectname(english1) but in my table2 i added studentnumber(s-0001) and studentname(paul) im...
3
by: Bethanabatla | last post by:
Table 1 ID Information 1 This is Key 2 This is Ball 3 This is Bike 4 This is Pen 5 This is Car Table 2 ID Member
0
by: virgo0984 | last post by:
Hi, I have a table 1 with the following values: ITEM LOCATION SS_DAYS 316TA/JP415 052 21 316TA/JP415 062 0 316TA/JT266 052 43.17...
3
by: satyamparmar | last post by:
I have data in table1 in form1. I want to copy data from selected row form table1 of Form1 to table2 of form2. After being selected from data from selected row of table1 should be deleted. I want...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.