简体   繁体   English

修复错误:“运算符不存在:没有时区的时间戳>整数”错误

[英]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_timet_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.

相关问题 错误:运算符不存在:没有时区的时间戳 > 整数) - ERROR: operator does not exist: timestamp without time zone > integer) 错误:运算符不存在:没有时区的时间戳+整数 - ERROR: operator does not exist: timestamp without time zone + integer 错误:运营商不存在:带时区的时间戳/integer - ERROR: operator does not exist: timestamp with time zone / integer ActiveRecord :: StatementInvalid:PG错误:错误:运算符不存在:没有时区的时间戳> =整数 - ActiveRecord::StatementInvalid: PGError: ERROR: operator does not exist: timestamp without time zone >= integer 运算符不存在:@timestamp without time zone - operator does not exist: @ timestamp without time zone 按日期获取查询 - 错误:运算符不存在:没有时区的时间戳~~未知 - Getting query by date - ERROR: operator does not exist: timestamp without time zone ~~ unknown PostgreSQL错误函数width_bucket(timestamp with time zone,timestamp without time zone[])不存在 - PostgreSQL error function width_bucket(timestamp with time zone, timestamp without time zone[]) does not exist 错误:运算符不存在:时间戳不带时区 >= 布尔值 提示:没有运算符匹配给定的名称和参数类型 - ERROR: operator does not exist: timestamp without time zone >= boolean Hint: No operator matches the given name and argument type(s) heroku Postgres错误 - 运算符不存在时区没有时区=整数 - heroku Postgres error - operator does not exist timestamp without timezone = integer PostgreSQL:运算符不存在:没有时区的时间戳==没有时区的时间戳 - PostgreSQL: operator does not exist: timestamp without time zone == timestamp without time zone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM