Returns the total number of values in a given column.
We have table as shown in figure that will be used to perform different aggregate functions. The table name is Marksheet.
Select COUNT(MarksObtained) From Marksheet
The count
function doesn't consider rows with NULL value in the field used as parameter. Usually the count parameter is * (all fields) so only if all fields of row are NULLs this row will not be considered
In the above example if we have another row like this:
106 Italian NULL
This row will not be consider in count calculation
NOTE
The function COUNT(*)
returns the number of rows in a table. This value can also be obtained by using a constant non-null expression that contains no column references, such as COUNT(1)
.
Example
Select COUNT(1) From Marksheet