edited by
1,450 views
1 votes
1 votes

Ideally  Count(*) will count no of rows in which atleast one column is Non NULL otherwise discard that row. Is this statement true?

But when I am trying practically it is returning the count including the null tuple where all columns are null. Can someone pls explain what should be the actual interpretation? And what should be the possible ans for Gate?

create table stud(id int, grade varchar(20));
insert into stud values(1, 'A');
insert into stud values(2, 'B');
insert into stud values(3, null);
insert into stud values(null, null);

select count(grade) from stud; // Returning 2 rows which is correct

select count(*) from stud; // Returning 4 rows. Is this correct?
edited by

1 Answer

5 votes
5 votes
No it is false.
null occupies a row, so if you do count(*) it will be counted.
However if you do count(A) //say one of the columns, then it won't take null into consideration as it is not a valid value.

Related questions

0 votes
0 votes
4 answers
1
ShiveshRoy asked Apr 1, 2016
2,097 views
What will COUNT(*) returns if all the collection has only null values???
0 votes
0 votes
1 answer
2
CKgurav asked Jan 1, 2016
1,223 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,...