![]() |
|
Archives of the TeradataForumMessage Posted: Thu, 09 Jun 2011 @ 10:20:03 GMT
Count(*) counts all occurrences including nulls. This is a row count. - Count (x) counts all non null occurrences of values in column x. If x has null values, count(x) will be less than count(*). - Count (1) is like count(x) it will count all null values in a "pseudo column" created by the constant. Since the constant 1 will never be null, this would, like count(*), give you a row count. Thus with this data in t3:
X y
1 1
Null 2
Null 3
4 4
And this query:
select count(*), count(x), count(1)
from t3;
you get:
4, 2, 4
| ||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||
| Copyright 2016 - All Rights Reserved | ||||||||||||||||||||||||||||||||||||||||||||||||
| Last Modified: 15 Jun 2023 | ||||||||||||||||||||||||||||||||||||||||||||||||