0

i have table_1 include some field, one field name is THROUGHPUT in char datatype(the value is number)

i want to use function avg() to get average value from all THROUGHPUT value in netezza,

i have tried code for convert to float :

SELECT Cast(THROUGPUT as float) AS A
FROM   WIFI.WID_NM_DETAIL
ORDER BY A

when i execute the code, i have error ERROR: Bad float8 input format '1,248.2',

i tried to another datatype, but still error

How can i fix it ?

Thx

ihsansat
  • 503
  • 2
  • 7
  • 20

1 Answers1

0

Depending what kind of format mask you use for displaying your throughput and what locale for your database you should either remove all commas or all dots. Assuming that the comma here separates the thousands, you can try one of these

CAST(REPLACE(throughput, '.', '') AS FLOAT)

or

CAST(TRANSLATE(throughput, ',', '') AS FLOAT)
Doug_Ivison
  • 778
  • 7
  • 17
sqlab
  • 6,412
  • 1
  • 14
  • 29