what does Sum(1) as column_name means in Teradata

General

what does Sum(1) as column_name means in Teradata

Hi,

I have query something like below, what does Sum(1) means here ? what will it do?

Sel

ABC, CED, SUM(1) AS COLUMN_NAME

FROM XYZ

INNER JOIN LMN

ON ABC = ABC

 


Accepted Solutions
Apprentice

Re: what does Sum(1) as column_name means in Teradata

Hi,

The SUM(1) in this example is generating a count of the number of rows for each combination of columns ABC and CED. The number is called COLUMN_NAME.

The same could be done with COUNT(*).

Cheers,

Dave

 

Ward Analytics Ltd - information in motion
www: http://www.ward-analytics.com
1 ACCEPTED SOLUTION
2 REPLIES
Apprentice

Re: what does Sum(1) as column_name means in Teradata

Hi,

The SUM(1) in this example is generating a count of the number of rows for each combination of columns ABC and CED. The number is called COLUMN_NAME.

The same could be done with COUNT(*).

Cheers,

Dave

 

Ward Analytics Ltd - information in motion
www: http://www.ward-analytics.com

Re: what does Sum(1) as column_name means in Teradata

Thanks a lot