Returns the number of (distinct) non-null values, or the number of selected rows as a bigint.
count_big([all | distinct] expression)
1> select count_big(name) from systypes 2> go -------------------- 42
When distinct is specified, count_big finds the number of unique non-null values. Null values are ignored when counting.
count_big(column_name) returns a value of 0 on empty tables, on columns that contain only null values, and on groups that contain only null values.
count_big(*) finds the number of rows. count_big(*) does not take any arguments, and cannot be used with distinct. All rows are counted, regardless of the presence of null values.
When tables are being joined, include count_big(*) in the select list to produce the count of the number of rows in the joined results. If the objective is to count the number of rows from one table that match criteria, use count_big(column_name).
select * from tab where 0 < (select count_big(*) from tab2 where ...)
select * from tab where exists (select * from tab2 where ...)
See also compute clause, group by and having clauses, select, where clause commands in Reference Manual: Commands
ANSI SQL – Compliance level: Transact-SQL extension.
Any user can execute count_big.