count versus count (*)

count finds the number of non-null values in an expression; count(*) finds the total number of rows in a table.

This statement finds the total number of books:
select count(*) 
from titles 
------------------ 
                18 
 
(1 row affected) 

count(*) returns the number of rows in the specified table without eliminating duplicates. It counts each row, including those containing null values.

Like other aggregate functions, you can combine count(*) with other aggregates in the select list, with where clauses, and so on:

select count(*), avg(price) from titles 
where advance > 1000 
---------- --------- 
        15     14.42 
 
(1 row affected)