sum(0)

Database
Enthusiast

sum(0)

What does this do?

 

select 

sum(0) as amt

...

 

Thanks!

 


Accepted Solutions
Teradata Employee

Re: sum(0)

in this case it puts a zero value in the field.

 

If they did not use sum, they would need to include those fields in the group by

 

dave

1 ACCEPTED SOLUTION
3 REPLIES
Teradata Employee

Re: sum(0)

It tells you if Teradata is available and a table is accessible without having to return any data.  Note that the use of sum() implies a From clause, so if "Select sum(0) from <table-or-view-name>" returns 0 then you know you can get to that table-or-view.  (A From clause is not always required in Teradata SQL, e.g., you can say, "Select 0," or "Select DATE," etc.)

Enthusiast

Re: sum(0)

 

 

Sorry I didn't include the complete query first time. Here it is. I can't figure out why the author put sum(0) in there......

 

image.png

Teradata Employee

Re: sum(0)

in this case it puts a zero value in the field.

 

If they did not use sum, they would need to include those fields in the group by

 

dave