Ximigo
05-20-2008, 03:21 AM
:confused:Table ATable C KeyA-DateA-QuantityEarlyOn TimeLateOut of ScheduleA1K12008-05-14280280A2K12008-05-14380380A3K12008-05-14240240A4K12008-05-14500200300A5K22008-05-145050A6K32008-05-1435030050A7K42008-05-14260260Table BTable D KeyB-DateB-QuantityA1A2A3A4A5A6B1K12008-04-13300-28020-20B2K12008-04-28300-300B3K12008-05-03300-60240-240B4K111/05/2008300-300B5K123/05/2008250-200B6K22008-04-20100-50B7K22008-05-13100B8K32008-05-18300-300
You can also see this tables in attachments.
There are two tables of records, both of them contain Key, Date and Quantity. Now I need to compare each record in table A with table B which have the same key, in order to judge how many A-Quantity is early, late, on time or out of schedule. The result is in Table C, the check process is in Table D. And we give ±3 days as a tolerance, which means if B-Date is 2008-05-07, as long as A-Date is between 2008-05-04 and 2008-05-10 it is considered as on time.
Recoreds in table A all have the same Date, and records in table B are sorted ascending by Date.
For record A1 in table A, the Key is K1, date is 2008-05-14 and quantity is 280. The first record of K1 in table B is record B1, whose quantity is 300. A1’s 280 comes on 2008-05-14, comparing to B1’s B-Date 2008-04-13, it is late, so put 280 under ”Late” in Table C. Obviously record A1’s 280 quantity can’t cover all of B1, there is still 20 left, we leave it to the next record to cover.
For record A2, A-Quantity is 380, first it should cover the 20 left from B1, and then cover 300 of B2. The rest 60 of 380 can give to record B3. Now compare A-Date with B-Date of B1, B2, B3, A2 is late for all of them, so we put all these 380 into “Late” in Table C.
The same story for A3, it covers B3, but A3’s A-Date is 2008-05-14, still late than B3’s B-Date 2008-05-03, so A3’s 240 fall into “Late” category.
Now check record A4 in Table A, according to Key in both table, it can cover record B4 and part of record B5. For B4’s B-Date, A4 is on time, so we put 300 to “On Time” category in Table C. But for B5’s B-Date 2008-05-23, A4’s A-Date 2008-05-14 is too early, so we put these 200 into “Early” category
For record A5, it only fills 50 to B6, and this 60 falls into “Late”. What we should notice is that there are totally two records of K2 in table B, since we can’t find any other K2 record besides A5 in table A, just leave B7 open.
For Record A6, after it covering B8’s 300, there is still 50 left, it has nothing to compare with, so we put it into “Out of Schedule”.
And Record A7, there is no record of K4 in table B, then the whole 260 quantity falls into “Out of Schedule” category.
There are around 2000 records in table A which needed to be checked one by one.
The whole process is so complex, and I’m just a beginner, really look forward and appreciate for your help!!
You can also see this tables in attachments.
There are two tables of records, both of them contain Key, Date and Quantity. Now I need to compare each record in table A with table B which have the same key, in order to judge how many A-Quantity is early, late, on time or out of schedule. The result is in Table C, the check process is in Table D. And we give ±3 days as a tolerance, which means if B-Date is 2008-05-07, as long as A-Date is between 2008-05-04 and 2008-05-10 it is considered as on time.
Recoreds in table A all have the same Date, and records in table B are sorted ascending by Date.
For record A1 in table A, the Key is K1, date is 2008-05-14 and quantity is 280. The first record of K1 in table B is record B1, whose quantity is 300. A1’s 280 comes on 2008-05-14, comparing to B1’s B-Date 2008-04-13, it is late, so put 280 under ”Late” in Table C. Obviously record A1’s 280 quantity can’t cover all of B1, there is still 20 left, we leave it to the next record to cover.
For record A2, A-Quantity is 380, first it should cover the 20 left from B1, and then cover 300 of B2. The rest 60 of 380 can give to record B3. Now compare A-Date with B-Date of B1, B2, B3, A2 is late for all of them, so we put all these 380 into “Late” in Table C.
The same story for A3, it covers B3, but A3’s A-Date is 2008-05-14, still late than B3’s B-Date 2008-05-03, so A3’s 240 fall into “Late” category.
Now check record A4 in Table A, according to Key in both table, it can cover record B4 and part of record B5. For B4’s B-Date, A4 is on time, so we put 300 to “On Time” category in Table C. But for B5’s B-Date 2008-05-23, A4’s A-Date 2008-05-14 is too early, so we put these 200 into “Early” category
For record A5, it only fills 50 to B6, and this 60 falls into “Late”. What we should notice is that there are totally two records of K2 in table B, since we can’t find any other K2 record besides A5 in table A, just leave B7 open.
For Record A6, after it covering B8’s 300, there is still 50 left, it has nothing to compare with, so we put it into “Out of Schedule”.
And Record A7, there is no record of K4 in table B, then the whole 260 quantity falls into “Out of Schedule” category.
There are around 2000 records in table A which needed to be checked one by one.
The whole process is so complex, and I’m just a beginner, really look forward and appreciate for your help!!