473,396 Members | 1,797 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.

Closest date

1
Hi. This is my first post, so, please, bear with me.
I have two tables:
FIRST:
Expand|Select|Wrap|Line Numbers
  1. ID    DataEmitere    DispIO
  2.  1    19.10.2011     0,00
  3.  2    19.10.2011     0,00
  4.  3    19.10.2011     0,00
  5.  4    19.10.2011     0,00
  6.  5    19.10.2011     0,00
  7.  6    19.10.2011     0,00
  8.  7    24.10.2011     0,00
  9.  8    24.10.2011     0,00
  10.  9    24.10.2011     0,00
  11. 10    24.10.2011     0,00
  12. 11    24.10.2011     0,00
  13. 12    31.10.2011     0,00
  14. 13    31.10.2011     0,00
  15. 14    14.11.2011     0,00
  16. 15    14.11.2011     0,00
  17. 16    18.11.2011     0,00
  18. 17    18.11.2011     0,00
  19. 18    18.11.2011     0,00
  20. 19    18.11.2011     0,00
  21. 20    23.11.2011     0,00
  22. 21    23.11.2011     0,00
  23. 22    23.11.2011     0,00
  24. 23    23.11.2011     0,00
  25. 24    29.11.2011     0,00
  26. 25    29.11.2011     0,00
  27. 26    30.11.2011     0,00
  28. 27    06.12.2011     0,00
  29. 28    09.12.2011     0,00
  30. 29    09.12.2011     0,00
  31. 30    09.12.2011     0,00
  32. 31    09.12.2011     0,00
  33. 32    09.12.2011     0,00
  34. 33    13.12.2011     0,00
  35. 34    13.12.2011     0,00
  36. 35    15.12.2011     0,00
  37. 36    15.12.2011     0,00
  38. 37    15.12.2011     0,00
  39. 38    15.12.2011     0,00
  40. 39    22.12.2011     0,00
  41. 40    22.12.2011     0,00
SECOND:
Expand|Select|Wrap|Line Numbers
  1. ID    Data    Suma
  2.  1    01.10.2011    17.027,76 lei
  3.  2    14.10.2011    4.121,00 lei
  4.  3    19.10.2011    5.355,00 lei
  5.  4    24.10.2011    3.645,00 lei
  6.  5    26.10.2011    4.964,00 lei
  7.  6    31.10.2011    3.402,00 lei
  8.  7    14.11.2011    2.196,00 lei
  9.  8    18.11.2011    8.844,00 lei
  10.  9    23.11.2011    5.122,00 lei
  11. 10    29.11.2011    8.829,00 lei
  12. 11    13.12.2011    4.050,00 lei
  13. 12    15.12.2011    3.700,00 lei
  14. 13    21.12.2011    6.162,00 lei
  15. 14    22.12.2011    3.260,00 lei
I would like, if possible, to insert values from the second table into the first on, according to "Data" field from both. The trick is that, the second table contains less rows and different dates than the first one.
Ex: TABLE 2 - Sum(ROW 1,2,3) --> TABLE 1 - ROW 1
TABLE 2 - ROW 4 --> TABLE 1 - ROW 7
TABLE 2 - Sum(ROW 5,6) --> TABLE 1 - ROW 12
... and so on.

The question is: can I do that with SQL or with VBA?
Mar 6 '12 #1
3 1791
Rabbit
12,516 Expert Mod 8TB
I have no idea how you're linking the two tables. It's unclear from your description.
Mar 6 '12 #2
NeoPa
32,556 Expert Mod 16PB
The answer is probably "Yes", but the question, though you've clearly put some effort into it, is not very clear.

Please explain the logic you are working to so that it makes sense. Example data is good, but is only useful to pad out or clarify an explanation. It's no good to use in place of one.
Mar 6 '12 #3
Mihail
759 512MB
Welcome to the forum, Tzeposule !
May I ask you why Sum(ROW 1,2,3) from Table 2 must go to Row 1 in Table 1 ? Why not in row 2 ? Or 3 or 4 ? For me looks the same (except the ID, o course).

More than: In what field in Table 1 you wish to put the result ?

I think is better to explain what you wish to achieve. And how you plan to do this (your logic).

I wish to remember that the forum rules say that you must answer in English.
If you wish to explain better in Romanian language you can send me a private message.
I wish to warn you: If you do that (send me PM) yo also must explain your problem HERE, in English.

Good luck !
Mar 6 '12 #4

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

Similar topics

8
by: Benny Chow | last post by:
Hello, I need help in writing a SQL statement in MS SQL Server 2000 to select the latest date (i.e., the date closest to or equal to the current date) for a given date. For example, in a...
3
by: Josh | last post by:
I need a query that will select the closest date. I have to tables Pricing and InventoryItem. tblInventoryItem InventoryItemID <- Pk Description tblPricing
1
by: sk | last post by:
I have the following table CREATE TABLE Readings ( ReadingTime DATETIME NOT NULL DEFAULT(GETDATE()) PRIMARY KEY, Reading int NOT NULL ) INSERT INTO Readings (ReadingTime, Reading)...
6
by: KoRnDragon | last post by:
I know about getlastmod() but is there one for created date? If not is there some other way of getting the created date of a file?
2
by: CK | last post by:
Good Morning, I have a view that contains rate information, contractIDs, and effective dates. I need to select the rate info based on contractID and date. I can provide a date and contractID, and...
3
by: randy1200 | last post by:
I have a DataView (dv) that includes a StartDate DateTime column. I'd like to return the DataView record that contains a StartDate value closest to my IncidentDate value: string filter =...
2
by: josecruz | last post by:
I hope this make sense... When students leave school (dropout, medical reasons, etc), there is a date field that admission use to record this event. For program evaluation, I want to know what...
1
by: CatherineA | last post by:
I need help writing an SQL statement in Access 2007 to select the closest date/time. I have Spot Time (the date/time commercials ran) and Call Time (the date/time we received calls). I need to...
7
by: GraemeC | last post by:
I have a form (single record form) that loads records from a query that are sorted date order as the records are viewed in date order. Some dates are in the past and some are in the future. Currently...
10
reginaldmerritt
by: reginaldmerritt | last post by:
I'm trying to open a form where the value of a field has a date closest to today but not beyond todays date. I guess i need some sort of MAX function in a where statment maybe???? Any ideas how...
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
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
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.