我有两个查询ORA-01722: invalid number
在尝试转换CHAR
为NUMBER
.
SELECT to_number('NYC TERM') FROM dual;
WITH
x AS (SELECT 'NYC TERM' AS col FROM dual
UNION
SELECT '33' FROM dual)
SELECT *
FROM X
ORDER BY to_number(col);
如果我删除查询中的第二个SELECT
工作UNION
正常。为什么它的行为不同?
问题是,当我作为一个整体运行查询返回其他行时,它会给出错误,但是当我只针对具有此类数据的特定记录运行时,它会正常运行。
WITH
x AS (SELECT 'NYC TERM' AS col FROM dual)
SELECT * FROM X ORDER BY to_number(col);