【发布时间】:2016-01-22 14:31:35
【问题描述】:
我还是 postgres 的新手。我想在查询的 SELECT 部分中有一个 SELECT 语句,但现在我遇到了一个错误。
SELECT cu.user_name, cu.created_date, cu.updated_date, cu.email_address,
cua.attribute_name, cua.attribute_value,
(select to_char(to_timestamp(cua.attribute_value / 1000), 'yyyy-mm-dd HH24:MI:SS')) AS Issue_Update
FROM cwd_user cu
INNER JOIN cwd_user_attribute cua ON cu.id = cua.user_id
WHERE cu.user_name LIKE 'perter%'
我收到以下错误:
错误:运算符不存在:字符变化/整数 第 3 行:(选择 to_char(to_timestamp(cua.attribute_value / 1000), '... ^ 提示:没有运算符与给定名称和参数类型匹配。您可能需要添加显式类型转换。
【问题讨论】:
-
你不能用 int 分割字符...
-
@a_horse_with_no_name 有没有办法在除法之前将其更改为整数?
-
cast(cua.attribute_value 为整数)
-
如果是数字,则将其存储为整数。请不将数字存储在
varchar列中。 -
@a_horse_with_no_name 我继承了数据库。
标签: sql postgresql subquery