Monday, October 13, 2008

Count()

The COUNT column function returns the total number of non-NULL values in the column or expression. The ALL keyword can precede the specified column name for clarity, bu the query result is the same whether you include the ALL keyword or omit it.

SELECT COUNT(ALL COL_NAME) FROM TABLE_NAME;

Count(1)
to get better performance as the database engine will not have to fetch back the data fields. Count(*) need to retrieve all fields from the table. Count(1) retrieve the numeric value of 1 for each record that meets your criteria.

No comments: