All Forums Database
DaZzL3R 20 posts Joined 12/06
02 Mar 2009
sql question

My question is, would following pull up row counts in floats? SELECT COUNT(*) (FLOAT) FROM DB.table;

Adeel Chaudhry 773 posts Joined 04/08
02 Mar 2009

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

-- If you are stuck at something .... consider it an opportunity to think anew.

DaZzL3R 20 posts Joined 12/06
02 Mar 2009

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?

Fred 1096 posts Joined 08/04
02 Mar 2009

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.

You must sign in to leave a comment.