我正在查看 Postgres RIGHT() function documentation , 对..
对于文档示例:
SELECT RIGHT('XYZ', 2);
我期望根据文档得到正确的响应;
right
-------
YZ
(1 row)
但后来我在 Aginity Workbench 中运行查询,结果不正确。我得到:
found "RIGHT" (at char 8) expecting an identifier found a keyword
有人可以纠正我吗?
最佳答案
right
函数仅从 Postgres 版本 9.1 开始可用。我猜测生成该错误消息的版本使用的是 9.0 或更早版本。
参见 documentation for 9.0它没有 right
函数,然后查看 documentation for 9.1这表明 right
可用。
作为解决方法,您可以使用 substr
:
select
substr('Hello World', char_length('Hello World') - 4, 5);
World
关于sql - Postgres 中的 RIGHT() 函数不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52068775/