From: Peter H. <ph...@ma...> - 2007-10-12 16:11:13
|
On Fri, Oct 12, 2007 at 12:28:45AM -0500, jsWalter wrote: > Here is a sample record set... Would an SQL query to do this be useful, or do you only have this data in an array? > 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. So you're selecting the rows for each date and line_num that have (or tie for) the highest line_num and seq_num. You don't mention whether cel_num or seq_num has higher priority. Which of these two rows would be selected? ID DATE line_num seq_num cell_num time 1 APM 2007-10-02 2 0 1 6.00 2 APM 2007-10-02 2 1 0 5.50 -- Peter Harkins - http://push.cx - http://NearbyGamers.com |