gpt4 book ai didi

sql - 错误 : function date_trunc(timestamp without time zone) does not exist

转载 作者:行者123 更新时间:2023-11-29 11:19:06 29 4
gpt4 key购买 nike

我有这个问题。我有一个 sql 查询正在尝试对我的 postgres 数据库进行。这些查询在 oracle 中运行良好,但正在将其转换为 postgres 查询,但它会提示。这是查询:

select  to_char(calldate,'Day') as Day, date_trunc(calldate) as transdate,
Onnet' as destination,ceil(sum(callduration::integer/60) )as total_minutes,round(sum(alltaxcost::integer) ,2)as revenue
from cdr_data
where callclass ='008' and callsubclass='001'
and callduration::integer >0
and regexp_like(identifiant,'^73')
and bundleunits = 'Money'
and inserviceresultindicator in (0,5)
and regexp_like(regexp_replace(callednumber,'^256','') ,'^73')
group by to_char(calldate,'Day') ,trunc(calldate),'Onnet' order by 2

我得到的错误是这样的:

Err] ERROR:  function date_trunc(timestamp without time zone) does not exist
LINE 4: select to_char(calldate,'Day') as Day, date_trunc(calldate)...

我做错了什么,或者这个错误的解决方案是什么?

最佳答案

尝试:

... date_trunc('day',calldate) ...

对于 PostgreSQL date_trunc() 函数,您必须始终将精度指定为第一个参数。

详情 here .

关于sql - 错误 : function date_trunc(timestamp without time zone) does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14340999/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com