Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 09 Jun 2011 @ 10:20:03 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Does Count(*) and count(1) has any difference?
 
From:   Gutta_Ram

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


     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023