VoltDB Home » Documentation » Using VoltDB


COUNT() — Returns the number of rows selected containing the specified column.


COUNT( column-expression )


The COUNT() function returns the number of rows selected for the specified column. Since the actual value of the column is not used to calculate the count, you can use the asterisk (*) as a wildcard for any column. For example the query SELECT COUNT(*) FROM widgets returns the number of rows in the table widgets, without needing to know what columns the table contains.

The one case where the column name is significant is if you use the DISTINCT clause to constrain the selection expression. For example, SELECT COUNT(DISTINCT last_name) FROM customer returns the count of unique last names in the customer table.


The following example returns the number of rows where the product name starts with the captial letter A.

SELECT COUNT(*) FROM product_list
    WHERE product_name LIKE 'A%';

The next example returns the total number of unique product categories in the product list.

SELECT COUNT(DISTINCT category) FROM product_list;