I'm in trouble with TO_NUMBER ORACLE function.
The query
SELECT TO_NUMBER(varchar2_column)
FROM TABLE@ANOTHER_DB;
works, but if I put TO_NUMBER inside AVG, ORACLE returns the following error:
ORA-01722: invalid number ORA-02063: preceding line from ANOTHER_DB Position: 0
The query is the following:
SELECT AVG(TO_NUMBER(varchar2_column))
FROM TABLE@ANOTHER_DB;
Could someone help me? Thanks in advance
whereclause in your actual query? Are you fetching all the data when you run the query with just ato_number? Or only the first few pages of data? Istable@another_dbactually a table? Or a view? Is there non-numeric data in the column? If so, how do you want to handle averaging numbers with, say, the string "abc"? Treat it as NULL? 0? Something else? - Justin CaveSELECT AVG(TO_NUMBER(varchar2_column DEFAULT NULL ON CONVERSION ERROR)) FROM TABLE@ANOTHER_DB- Radagast81