2,142 views

4 Answers

9 votes
9 votes

Aggregate function (like Count(), Sum(), Avg()) ignore null values.
Now what about count(*) ?

In case of Count (Marks) it count number of  NON NULL rows. Count(Marks) discards those rows in which Null is present. Here Domain is Marks Column.

Same Analogy with Count(*) also. It counts every non null rows. 
let there is Student table S and with attributes :  Name, DOB, Subject & Marks.

Now Count(*) count no of  row in which atl
east one column is Non NULL otherwise discard that row. If every column of a particular row is filled with NULL (which really not a good database) then count(*) also ignore that row. For Count(*) domain is all column so it will check null value in every column unlike Count(Marks) see NULL values only in Marks Column.


Count(), Count(*) both
excludes those rows in which every column is NULL.

7 votes
7 votes
In SQL,when we use the count function over an attribute of the relation and that attribute contains null values for some/all tuples of that relation than the null values will not be considered during the calculation.But if we use count(*) over some relation than it will consider the null values as well.So count(*) will return count of all the tuples in that relation.
2 votes
2 votes

count(*) will return count of all the non-null  tuples in the relation & ignore the count for tuples with all null values.

Related questions

0 votes
0 votes
1 answer
4
CKgurav asked Jan 1, 2016
1,263 views
How aggrigate functions in query will behave in data contains NULL values.I think answer should be D as all aggrigatre functions EXCEPT count will ignore NULL values. so,...