我正在使用 sum 函数来查找总数,但出现错误。这是查询:
select sum(col1)
from table_name
where col2="abc"
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)Error: function sum(text) does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts
Tim*_*sen 10
假设该text列包含文本数字,而不是实际整数,那么它将解释您所看到的错误。您可以通过首先转换text为整数,然后求和来解决这个问题:
SELECT SUM(text::int)
FROM yourTable;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6622 次 |
| 最近记录: |