June 10, 200718 yr I have a database with a little more than 1 million records where a very simplified version of 1 table looks like this. Record.....ID_Field....Log_in 1.............1234........1 2.............1234........2 3.............1234........2 4.............1234........4 5.............1234........2 6.............1234........3 7.............1234........4 I need to run a looping script that will look for the highest number in field 2 and then assign it to all of the records in a third field so it looks something like this. Record.....ID_field....Log_in.....NumLogIn 1.............1234........1..........4 2.............1234........2..........4 3.............1234........2..........4 4.............1234........4..........4 5.............1234........2..........4 6.............1234........3..........4 7.............1234........4..........4 Can anyone help me write this? Thank you, Steve
June 10, 200718 yr Sort the records by field two, get the value from the first or last record (depending which way you sort it), then simply: Sort Records[by Field 2, decsending] Go To Record / Request [First] Set Variable [ $maxValue ; Table::Field_2 ] Loop Set Field[ Table::Field_3 ; $maxValue ] Go To Record / Request [Next ; Exit After Last] End Loop Edited June 10, 200718 yr by Guest
June 10, 200718 yr Oh and as a side note, rather than looping, you could probably just use the replace field contents script step which should replace all the contents at once, but the quesiton of why still remains.
June 10, 200718 yr As Genx asks, why are you wanting this because looping through a million records is major bummer and I would bet there are better ways to accomplish what you wish ... OR ... something is lacking in your existing structure. Why not create a self-join relationship based upon Main::ID Field = SelfJoin::ID Field. Then a calculation (number) of Max ( selfJoin:: Log_In) or, if the largest Log_In is always last then Last( selfJoin:: Log_In ) should give you what you wish. Still, I would bet a good structure would eliminate the need for an aggregate calc entirely. LaRetta Edited June 10, 200718 yr by Guest
Create an account or sign in to comment