sql question

Database
Enthusiast

sql question

My question is, would following pull up row counts in floats?

SELECT COUNT(*) (FLOAT) FROM DB.table;
3 REPLIES
Teradata Employee

Re: sql question

Hello,

As far as my limited knowledge is concerned, I genuinely believe rows can be 1, 2.... but not 1.1, 2.75, 3.0008. Am I missing something?

Regards,

Adeel
Enthusiast

Re: sql question

Yes, i have seen that and I would use numbers rather floats...but for some reason one developer did SELECT COUNT(*) (FLOAT) FROM DB.table; not sure what is he trying to achieve, cannot ask him no longer works on the project.... :( any explanation for this syntax that my brain is unable to come up with? anyone?
Teradata Employee

Re: sql question

In Teradata mode, COUNT(*) returns an INTEGER by default.

You are correct that CAST to FLOAT makes sense only if you want an approximate "order of magnitude" answer. But you may want to CAST to BIGINT or DECIMAL to avoid an overflow if you have billions of rows.