我正在尝试这样运行查询
select * from mytable where to_number(minutesintext, '9999') >= 10;
expected result:
col1 | col2 | col3 | minutesintext
-------------------------------------
a | b | c | 11
f | g | e | 98
但我经常遇到这个错误:
[22P02] ERROR: invalid input syntax for type numeric: " "
我已经看到 to_number() 的示例用法都是:
select to_number('45', '9999');
results in:
45
并且似乎找不到将 to_number() 函数用作条件子句一部分的示例。我究竟做错了什么?以及如何在查询期间将整数(存储为文本)转换为数字时查询所有行。
*更改列的数据类型是不可能的,因为它需要存储为文本。
我在本地使用 PostgreSQL 13.1,在远程环境使用 PostgreSQL 11
任何帮助表示赞赏!:)