Difference between revisions of "COUNT"
Barrymavin (Talk | contribs) (→Products) |
Yvonne.milne (Talk | contribs) |
||
(8 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Count records in the active table that satisfy a specified condition | Count records in the active table that satisfy a specified condition | ||
− | |||
==Syntax== | ==Syntax== | ||
− | COUNT [<scope>] | + | COUNT |
+ | |||
+ | [IN <workarea>|<alias>] | ||
+ | |||
+ | [<scope>] TO <memvar> | ||
[FOR <condition>] | [FOR <condition>] | ||
− | |||
− | |||
[WHILE <condition>] | [WHILE <condition>] | ||
− | |||
==See Also== | ==See Also== | ||
− | + | [[AVERAGE]], [[LOCATE]], [[SEEK]], [[SET DELETED]], [[SET FILTER]], [[SUM]], [[TOTAL]] , [[CALCULATE]] | |
− | + | ||
==Description== | ==Description== | ||
− | The COUNT command counts the number of records in the active table. If no <scope> is specified, ALL records will be counted. If SET FILTER TO is in effect, then only those records that satisfy the filter <condition> are counted. If SET DELETED is ON, then records marked for deletion will not be included in the COUNT. | + | The COUNT command counts the number of records in the active table and stores the total to <memvar>. If no <scope> is specified, ALL records will be counted. If SET FILTER TO is in effect, then only those records that satisfy the filter <condition> are counted. If SET DELETED is ON, then records marked for deletion will not be included in the COUNT. |
+ | |||
+ | ====IN <workarea>|<alias>==== | ||
+ | If the workarea number, letter or alias name is specified, the COUNT is carried out in that workarea. Note, the IN clause must be the first clause. From v6.0. | ||
====FOR <condition>==== | ====FOR <condition>==== | ||
If the for <condition> is used then only the records that satisfy the specified <condition> are counted. | If the for <condition> is used then only the records that satisfy the specified <condition> are counted. | ||
− | |||
− | |||
− | |||
====WHILE <condition>==== | ====WHILE <condition>==== | ||
The WHILE clause can be used in conjunction with the SEEK or LOCATE commands to restrict the range of records counted. When the WHILE option is used the <scope> defaults to REST. | The WHILE clause can be used in conjunction with the SEEK or LOCATE commands to restrict the range of records counted. When the WHILE option is used the <scope> defaults to REST. | ||
− | |||
==Example== | ==Example== | ||
Line 35: | Line 33: | ||
count to nResult for event = "CHOPIN" and date = date() | count to nResult for event = "CHOPIN" and date = date() | ||
</code> | </code> | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Commands]] | [[Category:Commands]] | ||
− | [[Category: | + | [[Category:NoSQL Commands]] |
− | + | ||
− | + |
Latest revision as of 08:03, 4 January 2021
Contents
Purpose
Count records in the active table that satisfy a specified condition
Syntax
COUNT
[IN <workarea>|<alias>]
[<scope>] TO <memvar>
[FOR <condition>]
[WHILE <condition>]
See Also
AVERAGE, LOCATE, SEEK, SET DELETED, SET FILTER, SUM, TOTAL , CALCULATE
Description
The COUNT command counts the number of records in the active table and stores the total to <memvar>. If no <scope> is specified, ALL records will be counted. If SET FILTER TO is in effect, then only those records that satisfy the filter <condition> are counted. If SET DELETED is ON, then records marked for deletion will not be included in the COUNT.
IN <workarea>|<alias>
If the workarea number, letter or alias name is specified, the COUNT is carried out in that workarea. Note, the IN clause must be the first clause. From v6.0.
FOR <condition>
If the for <condition> is used then only the records that satisfy the specified <condition> are counted.
WHILE <condition>
The WHILE clause can be used in conjunction with the SEEK or LOCATE commands to restrict the range of records counted. When the WHILE option is used the <scope> defaults to REST.
Example
use patrons count to nResult for event = "CHOPIN" and date = date()