Options

Find Max Value

johndimjohndim Member Posts: 17
i have a table and i want to get the max value of a field (type integer) .
any help ?

Comments

  • Options
    ara3nara3n Member Posts: 9,256
    Create a key for that field (integer). Set currentkey on that new key. and do Find('+').
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    krikikriki Member, Moderator Posts: 9,090
    2 possibilities.

    1) you read every record in the table and keep the biggest one in memory, but depending on the number of records, it can take a lot of time to find it.

    2) put a new index on it and when you need it do:
    MyRecord.RESET;
    MyRecord.SETCURRENTKEY("My Integer");
    IF MyRecord.FIND('+') THEN
    MESSAGE('The biggest value is %1',MyRecord."My Integer");
    This option slows down a little on writing in that table but reading is lightning fast.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    johndimjohndim Member Posts: 17
    Thank you very much both
Sign In or Register to comment.