[英]Fix ERROR: "operator does not exist: timestamp without time zone > integer" error
Im trying to migrate queries from Google big query to postgresql, and Im getting this error我试图将查询从谷歌大查询迁移到 postgresql,我得到了这个错误
ERROR: operator does not exist: timestamp without time zone > integer错误:运算符不存在:没有时区的时间戳 > 整数
select *, DATE(_modification_time) as modification_date,
CASE WHEN t_start>0 THEN DATE(t_start) END as start_date,
CASE WHEN _creation_time>0 THEN DATE(_creation_time) END as creation_date,
CASE WHEN t_finish>0 THEN DATE(t_finish) END as finish_date,
'WMT' as source
from public.set_list
You are trying to compare a timestamp
value with an integer (0).您正在尝试将timestamp
值与整数 (0) 进行比较。 This is not allowed in Postgres.这在 Postgres 中是不允许的。 Instead, you can turn the timestamp into an integer by using the extract function and getting the number of seconds since the start of the Unix epoch (1970-01-01 00:00:00), which is an integer, then compare that with the integer 0, like this:相反,您可以使用 extract 函数将时间戳转换为整数,并获取自 Unix 纪元 (1970-01-01 00:00:00) 开始以来的秒数,这是一个整数,然后将其与整数 0,像这样:
select *, DATE(_modification_time) as modification_date,
CASE WHEN extract(EPOCH FROM t_start) > 0
THEN DATE(t_start) END as start_date,
CASE WHEN extract(EPOCH FROM _creation_time) > 0
THEN DATE(_creation_time) END as creation_date,
CASE WHEN extract(EPOCH FROM t_finish) > 0
THEN DATE(t_finish) END as finish_date,
'WMT' as source
from public.set_list
However, I doubt that this is what you want as it means you are comparing if any of those values t_start
, _creation_time
and t_finish
is later than 1970-01-01 00:00:00.但是,我怀疑这是否是您想要的,因为这意味着您正在比较这些值中的任何一个t_start
、 _creation_time
和t_finish
是否晚于 1970-01-01 00:00:00。 Perhaps you can share a bit more about what you are trying to accomplish here.也许你可以在这里分享更多关于你想要完成的事情。 This would help you get more focused answers.这将帮助您获得更集中的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.