Export (0) Print
Expand All

COUNTA Function

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

The COUNTA function counts the number of cells in a column that are not empty. It counts not just rows that contain numeric values, but also rows that contain nonblank values, including text, dates, and logical values.





The column that contains the values to be counted

A whole number.

If you do not need to count cells that contain logical values or text (in other words, if you want to count only cells that contain numbers), use the COUNT or COUNTX functions.

When the function does not find any rows to count, the function returns a blank.  When there are rows, but none of them meet the specified criteria, then the function returns 0.

The following example returns all rows in the Reseller table that have any kind of value in the column that stores phone numbers. Because the table name does not contain any spaces, the quotation marks are optional.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft