Differences Between MIN(), MAX(), & SQL SELECT MIN/MAX

ID: Q98362

The information in this article applies to:

There are distinct differences between the MIN() and MAX() functions and the SQL SELECT MIN() and MAX() field functions. The SQL SELECT MIN() and MAX() field functions accept only one argument, whereas the MIN() and MAX() functions accept multiple arguments.

The following examples demonstrate how each function would be used in a FoxPro program.

   SELECT MIN(price) from detail
     && This statement will select the record with lowest price
     && in the database.

   SELECT MIN(IIF(price < 0,0,price)) FROM detail
     && This statement will select the record with the lowest price
     && as long as it is not less than zero; if it is less than zero,
     && it will return zero (0).

   ?MIN(54, 39, 40)
     && This statement will return the minimum of the three parameters
     && (39).

   ?MAX(54, 39, 40)
     && This statement will return the maximum of the three parameters
     && (54).

   SELECT MIN(price,0) from detail
     && This statement will cause the error " MISSING ) " to occur.
     && To correct this statement, remove the second argument from
     && the MIN() function, as shown in the first example.

Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a errmsg error message parameters err msg KBCategory: kbprg kberrmsg KBSubcategory: FxprgSql

Last Reviewed: June 27, 1995