Mandu Posted January 21, 2011 Share Posted January 21, 2011 What is the easiest way to compute the highest serial number in a column, in FM10? The serial numbers are of the form P-000002 - that is, fixed-width integer with alpha prefix (thus unusable by the max() function). If sort / goto record is the only way, so be it - just thought there might be a better way. Thanks, Chap Link to comment Share on other sites More sharing options...
Aussie John Posted January 21, 2011 Share Posted January 21, 2011 Without going into detail you could strip out the "P-" and use the remainder in the MAX function. Link to comment Share on other sites More sharing options...
Raybaudi Posted January 21, 2011 Share Posted January 21, 2011 ...thus unusable by the max() function). Hi what about using the Min ( ) function ? Try this calculation: "P-" & Right ( "000000" & Abs ( Min ( YourSerial ) ) ; 6 ) Note that this will work ONLY if your serial is always in the format: P-nnnnnn Link to comment Share on other sites More sharing options...
comment Posted January 21, 2011 Share Posted January 21, 2011 Min ( YourSerial ) I don't think that's a valid expression (unless YourSerial is a repeating field). My impression is that OP wants the highest serial number in a found set, and cannot use a summary field for this. We need to know if the prefix character is always a single "P". Link to comment Share on other sites More sharing options...
Raybaudi Posted January 21, 2011 Share Posted January 21, 2011 I don't think that's a valid expression (unless YourSerial is a repeating field). My impression is that OP wants the highest serial number in a found set, and cannot use a summary field for this. We need to know if the prefix character is always a single "P". YourSerial was an abbreviation for a self-related field, commonly used for the Summary functions, but you are right... it is better to specify: "P-" & Right ( "000000" & Abs ( Min ( CartesianSelfJoin::YourSerial ) ) ; 6 ) He said that cannot use the Max( ) function, so I think that he needs the max from all the records. Link to comment Share on other sites More sharing options...
comment Posted January 21, 2011 Share Posted January 21, 2011 Well. if you have a x self-join, you could sort it by the serial, descending. Then SelfJoin::YourSerial would be the answer. Link to comment Share on other sites More sharing options...
Raybaudi Posted January 21, 2011 Share Posted January 21, 2011 Of couse, your answers are always the best :) Link to comment Share on other sites More sharing options...
bcooney Posted January 21, 2011 Share Posted January 21, 2011 No warning that calculating keys can be error-prone, guys? Seems like that's what the OP is doing.. Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 4838 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now