Counting with SQL COUNT()

Home » Counting with SQL COUNT()

The SQL COUNT() aggregate function should be used to count the number of rows that match a condition (something that should never be done directly in CFML itself). But when counting, does COUNT() include rows with NULL values or not? The answer is – it depends. If you specify COUNT(*) then all rows are counted, including those with NULL values. But if you pass a column name to COUNT() only rows that have actual values in that column will be counted – rows with NULL will not. (Applies to: ColdFusion All)

Leave a Reply