Max(), Min()

These two functions take a list of values and return either the largest or smallest value in the list. Any of the numeric types (Numeric, Float, Integer, Currency, Double) can be used, as well as character, memo, date and datetime expressions. The result of numeric comparisons is Numeric unless all the values passed in are Currency, in which case the result is Currency. If Dates and Datetimes are mixed, Datetime is the result. All Memo and Character comparisons return type Character. General, Screen and Object variables yield an "Operator/operand type mismatch" or "Data type mismatch," as you might expect.

Usage

nReturnValue = MAX( nExpr1, nExpr2 [, nExpr3 ... ] )
nReturnValue = MIN( nExpr1, nExpr2 [, nExpr3 ... ] )
Like the other numeric functions, MAX() and MIN() propagate nulls. This means if one of the values passed in is .NULL., you get back .NULL. If you need the minimum or maximum of the non-null values, use CALCULATE or SELECT-SQL instead. Of course, you'll need to put the values in a table to use those commands, but with CREATE CURSOR and INSERT INTO around, that's not such a big deal.MAX() and MIN() are limited to 26 expressions per call. The official explanation is that you're allowed to pass 24 more than the required number, which is two; go figure. We don't think we've actually ever passed more than three, so the limit doesn't seem like much of a big deal.

Example

?MAX(27,39,-203)   && Returns 39
?MIN(27,39,-203)   && Returns -203
 
nHighValue=MAX(nUser1,nUser2,nUser3)

See Also

Calculate, Select-SQL


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .