Hi,
I have three tables as below:
Table: Demand
ITEM_ID, QUANTITY
Item A, 10
Table: Route
ITEM_ID, OPERATION_NO, RESOURCE, TIME
Item A, 10, RES1, 60
Item A, 20, RES2, 120
Item A, 30, RES3, 60
Table: Load
RESOURCE, LOAD
RES1, 600
RES2, 1200
RES3 , 600
The values in LOAD field of the LOAD table are calculated values.
What I want to achieve?
I want to calculate the LOAD field in the LOAD table
Steps:
1) Select the records for every ITEM_ID (e.g. Item A ) in the Route table.
2) Start with the lowest number of Operation_No (e.g. Operation_No 10), check the following:
a. Value in the RESOURCE field (e.g. Res1) and value in the TIME field (e.g. 60).
3) Multiply the value in the ROUTE.TIME field with the corresponding value in DEMAND.QUANTITY. (ROUTE.ITEM_ID = DEMAND.ITEM_ID)
4) Update the Table Load with the following values:
a. RES1 in field RESOURCE
b. The multiplied product we got in Step 3 above in the LOAD.LOAD field.
5) Go back to Step 2 above and select the next lowest record for Item A ( Operation_No = 20 in this case) and perform the following steps:
a. Step 2.a
b. Step 3
c. Step 4
6) Go back to Step 2. Continue this iteration (loop) until we complete all the records for this item. (In this case, there are three records for Item A: Operation_No: 10, 20 & 30).
7) Once all the records for Item A are processed and the LOAD table is updated, then go back to Step 1 and select the next item.
2 1793
Hi,
I have three tables as below:
Table: Demand
ITEM_ID, QUANTITY
Item A, 10
Table: Route
ITEM_ID, OPERATION_NO, RESOURCE, TIME
Item A, 10, RES1, 60
Item A, 20, RES2, 120
Item A, 30, RES3, 60
Table: Load
RESOURCE, LOAD
RES1, 600
RES2, 1200
RES3 , 600
The values in LOAD field of the LOAD table are calculated values.
What I want to achieve?
I want to calculate the LOAD field in the LOAD table
Steps:
1) Select the records for every ITEM_ID (e.g. Item A ) in the Route table.
2) Start with the lowest number of Operation_No (e.g. Operation_No 10), check the following:
a. Value in the RESOURCE field (e.g. Res1) and value in the TIME field (e.g. 60).
3) Multiply the value in the ROUTE.TIME field with the corresponding value in DEMAND.QUANTITY. (ROUTE.ITEM_ID = DEMAND.ITEM_ID)
4) Update the Table Load with the following values:
a. RES1 in field RESOURCE
b. The multiplied product we got in Step 3 above in the LOAD.LOAD field.
5) Go back to Step 2 above and select the next lowest record for Item A ( Operation_No = 20 in this case) and perform the following steps:
a. Step 2.a
b. Step 3
c. Step 4
6) Go back to Step 2. Continue this iteration (loop) until we complete all the records for this item. (In this case, there are three records for Item A: Operation_No: 10, 20 & 30).
7) Once all the records for Item A are processed and the LOAD table is updated, then go back to Step 1 and select the next item.
Can you post a reply to this question on Wednesday/Thursday to bump it up the list as it may not get much attention over the holidays.
Merry Christmas
Mary
NeoPa 32,556
Expert Mod 16PB
Try this : - SELECT R.Resource,Sum(D.Quantity * R.Time) AS Load
-
FROM Demand AS D
-
INNER JOIN Route AS R
-
ON (D.Item_ID=R.Item_ID)
-
GROUP BY R.Resource
-
ORDER BY R.Resource
It won't update the Load table (not a good idea) but will return the records you need as the results of a query.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: shank |
last post by:
I have a recordset that contains multiple records of product a user is
purchasing. For clarity, I converted the recordset fields to variables. I
need to take that entire recordset and insert it...
|
by: Sans Spam |
last post by:
Greetings! I have a table that contains all of the function
permissions within a given application. These functions are different
sections of a site and each has its own permissions (READ, WRITE,...
|
by: JMCN |
last post by:
i am running into problems with is the recordset. i have exactly 104
records. when i tested the code, the end result was multiple records
for the same loan(ET LN Shortname). where did i go wrong? ...
|
by: Charlie |
last post by:
Hello,
I have data in an Access table that I would like to export to multiple
HTML tables. I would like to split the data in the Access table
(about 92,000 records) into multiple HTML...
|
by: Robert Brown |
last post by:
Hi All.
I have a routine that checks a SQL Table for all records 3 months
prior to a predetermined date, then I insert them into an Archive DB
then delete those records from the original table....
|
by: MP |
last post by:
Hi
trying to begin to learn database using vb6, ado/adox, mdb format, sql
(not using access...just mdb format via ado)
i need to group the values of multiple fields
- get their possible...
|
by: dan |
last post by:
within a loop i am building a sql insert statement to run against my
(programatically created) mdb. it works but it seems unreasonably SLOW!
Sorry, dont have the code here but the jist is very...
|
by: mctime |
last post by:
Hello,
I am attempting to split a raw data table into a new table that has
split out a specific field in the raw data and created a new record
for each split but I have come to an impasse due to...
|
by: chumlyumly |
last post by:
Hello scripters -
OS: Mac OSX
Language: PHP w/ MySQL database
I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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: 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...
| | |