繁体   English   中英

将Oracle Query转换为PostgreSQL

[英]Conversion of Oracle Query to PostgreSQL

我将查询的一部分发布在Oracle中,如下所示:

cast(from_tz(cast((Select max(d.startdate) from Public.result_slalom d 
               where d.eventid = a.eventid 
               and d.modifydate = (Select max(e.modifydate) from result_slalom e 
                where e.eventid = d.eventid)) as timestamp), 'Asia/Calcutta') at Time Zone 'Europe/Berlin' as date) as OpenLastTime,

我想在PostgreSQL上运行此查询。 因此,我为PostgreSQL编写了一个查询,如下所示:

(Select Cast(to_timestamp(max(d.startdate)) 
                      from Public.result_slalom d 
               where d.eventid = a.eventid 
               and d.modifydate = (Select max(e.modifydate) from Public.result_slalom e
                where e.eventid = d.eventid) as timestamp, 'Asia/Calcutta') at Time Zone 'Europe/Berlin' as date) as OpenLastTime,

我到处都有一些错误,我认为这与某些括号问题有关。 或由于e.modifydate的第二个选择子句中的关键字“时间戳”。

任何帮助将非常感激。 提前致谢。 :)

将来,请尝试包含我们可以实际运行的完整可复制示例 我做了一个示例小提琴,展示了如何做到这一点

from_tz不是Postgres函数。 另外,Postgres中的date类型没有时间或时区部分-只是年月日。 您的startdatemodifydate列将需要为timestamp类型。

这是我的转换:

select ((Select max(d.startdate) from result_slalom d 
           where d.eventid = a.eventid and 
           d.modifydate = (Select max(e.modifydate) from result_slalom e 
             where e.eventid = d.eventid)) at time zone 'Asia/Calcutta') 
        at Time Zone 'Europe/Berlin' as OpenLastTime
from a;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM