Versions available for this page: CUBRID 8.2.1 | CUBRID 8.3.0 | CUBRID 8.3.1 | CUBRID 8.4.0 | CUBRID 8.4.1 | CUBRID 8.4.3 | CUBRID 9.0.0 |
The COUNT function returns the number of instances in the query results with an entered expression. It also calculates the number of attributes that have a collection attribute and object domain (user-defined class or multimedia class). If the expression is specified in the brace, only instances that are not NULL can be counted. If wildcard (*) is specified, however, all instances are counted even though some instances are duplicated or having NULL. In addition, COUNT function never returns NULL, only returns numbers.
COUNT ( * | [ DISTINCT | UNIQUE | ALL ] expression )
The COUNT function returns the number of instances for an expression in the parentheses. All instances that meet the conditions of the WHERE clause can be counted by specifying a wildcard (*) symbol. A unique value can be counted by specifying a DISTINCT or UNIQUE keyword before the expression.
The following is an example of returning the number of Olympic Games that had a mascot.
SELECT COUNT
FROM olympic
WHERE mascot IN NOT NULL;
Result : 9