Finding the Maximum or Minimum Value by Alphabetic Order

Last reviewed: June 27, 1995
Article ID: Q115420
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5x, 2.6, 2.6a
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6, 2.6a
  • Microsoft FoxPro for Macintosh, versions 2.5b, 2.5c

SUMMARY

This article shows three methods for finding the minimum or maximum value by alphabetic order in a field.

MORE INFORMATION

Method 1: Calculation

   CALCULATE MAX(<char_field>) TO <variable_name>

The variable now contains the lowest letter record value. For example, ZZZZZ versus BBBBB.

NOTE: To get the highest letter record value, replace MAX with MIN.

Method 2: Indexing

   INDEX ON <char_field> TAG <tag_name> OF <index_name>
   SET ORDER TO <tag_name>
   ***To obtain the lowest letter record value, do the following:
   GO BOTTOM
   <variable_name>=<char_field>
   ***To obtain the highest letter record value, do the following:
   GO TOP
   <variable_name>=<char_field>

Method 3: Indexing/LOCATE

   INDEX ON <char_field> TAG <tag_name> OF <index_name>
   ***To obtain the highest letter record value, do the following:
   SET ORDER TO <tag_name> ASCENDING
   LOCATE
   <variable_name>=<char_field>
   ***To obtain the lowest letter record value do, the following:
   SET ORDER TO <tag_name> DESCENDING
   LOCATE
   <variable_name>=<char_field>


Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.60
2.50c
phonetic ASCII
first last 2.60a
KBCategory: kbprg kbcode
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.