COUNT Command

The COUNT command displays the number of items in a file that meet specified conditions. This command summarizes the frequency with which a specific data element occurs in a database. For example, you might want to count the number of customers who live in a certain city.

Format

COUNT [DICT] filename [item-list] [selection] [modifiers] [(options)

Parameter(s)

DICT

Specifies the file dictionary.

filename

Name of the file.

item-list

List of individual item-IDs. Enclose each item-ID in single quotes.

selection

Specifies one or more conditions that an item must meet to be selected. For a complete description of selection expression syntax, see the LIST Command.

modifiers

Include one or more keywords that specify the report format. These parameters affect headers, footers, spacing, totalling column figures, control breaks, and more. For complete information about using these keywords, see the section, Connectives, Modifiers, and Options in the INFO/ACCESS User Reference Guide.

options

Include one or more single-character codes that specify the report format and direct or modify output. They must be enclosed in parentheses, can be entered in any order, and need not be separated by spaces or any delimiters such as commas. For complete information about using these parenthetical options, see the section, Connectives, Modifiers, and Options in the INFO/ACCESS User Reference Guide.

 

NOTE

Do not confuse the COUNT command with the mvBASIC COUNT function.

Counting Items in a File

The following example counts the total number of items in the ORDERS file:

>COUNT ORDERS

543 ITEMS COUNTED.

Counting Items that Meet Specified Conditions

The following example counts the number of items in the ORDERS file that have a value of more than $100 for the attribute AMOUNT:

>COUNT ORDERS WITH AMOUNT > "100"

352 ITEMS COUNTED.

The next example counts the number of items that meet the preceding conditions and whose sale date is before December 31, 1987:

>COUNT ORDERS WITH AMOUNT > "100" AND WITH DATE < "12/31/87"

231 ITEMS COUNTED.