From: Richard L. <ce...@l-...> - 2007-10-16 19:19:08
|
On Fri, October 12, 2007 12:28 am, jsWalter wrote: > I have a very unusual case on my hands. > > I'm working with a 3rd party AR/Time mgt system from hell! > > The time sheets are being particularly difficult. And no, I can't > change > the schema, change the system, use linux, or anything else in that > vane. I > have to use what I have. > > Here is a sample record set... > > ID DATE line_num seq_num cell_num time > 1 APM 2007-10-01 1 0 0 8.00 > 2 APM 2007-10-01 1 1 0 8.00 > 3 APM 2007-10-02 1 0 0 0.50 > 4 APM 2007-10-02 2 0 0 6.50 > 5 APM 2007-10-02 2 0 1 6.00 > 6 APM 2007-10-02 2 0 2 5.50 > 7 APM 2007-10-02 3 0 0 1.00 > 8 APM 2007-10-02 3 0 1 0.50 > 9 APM 2007-10-02 4 0 0 1.00 > 10 APM 2007-10-02 4 0 1 1.25 > 11 APM 2007-10-03 1 0 0 1.25 > 12 APM 2007-10-03 1 0 0 2.25 > > What I need to do is pull out it the time for each day. This example > has 3 > days. > > If you look at line 1 and 2, I would use line #2 because it has 2 > LINE_NUM > that are the same, but the second SEQ_NUM is higher. So I keep it. > > Lines 3 through 12 are the same date, with 5 sets of LINE_NUMs. > - #3 we keep, it is unique > - #6 we keep, because it's CEL_NUM is highest, even though it has the > same LINE_NUM and SEQ_NUMs > - #8 & #10 we keep, same reason as #6 > - we keep both 12 & 12 because the have the same numbers all across > the 3 > fields. > > Confused!? > > Steps, as I see them... > 1 - collect in an array date sets > 2 - collect into an array of LINE_NUM sub-sets by date > 3 - collect into an array of LINE_NUM by LINE_NUM by date > 4 - collect into an array of SEQ_NUM by LINE_NUM by LINE_NUM by date > 5 - SEQ_NUM value has the time for that record > > 2007-10-01 -> 1 -> 0 -> 0 = 8.00 > -> 1 -> 1 -> 0 = 8.00 > > 2007-10-02 -> 1 -> 0 -> 0 = 0.50 > -> 2 -> 0 -> 0 = 6.50 > -> 2 -> 0 -> 1 = 5.00 > -> 2 -> 0 -> 2 = 5.50 > -> 3 -> 0 -> 0 = 1.00 > -> 3 -> 0 -> 1 = 0.50 > -> 4 -> 0 -> 0 = 1.00 > -> 4 -> 0 -> 1 = 1.25 > > 2007-10-03 -> 1 -> 0 -> 0 = 1.25 > -> 1 -> 0 -> 0 = 2.25 > > Using indexed arrays I get... > > 2007-10-01 -> 1 -> 1 -> 0 = 8.00 > > 2007-10-02 -> 1 -> 0 -> 0 = 0.50 > -> 2 -> 0 -> 2 = 5.50 > -> 3 -> 0 -> 1 = 0.50 > -> 4 -> 0 -> 1 = 1.25 > > 2007-10-03 -> 1 -> 0 -> 0 = 2.25 > > This is 90% of what I need. > > 10-01 and 10-02 give me the result I need form the data they have, but > 10-03 fails. Because both SEQ_NUM and CEL_NUM are the same, I need to > keep > both of them. > > So, any minds greater than mine see anyway to do this? Without > convoluted > conditionals? If you are correct about the steps, then the conditionals with good variable names should not be that confusing... You could also consider pulling it all into SQL. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? |