当我在postgresql中执行mysql查询时,它显示错误。我在google中搜索了错误,但它们对我不起作用。请建议我解决。
下面是mysql查询:
SELECT caller_id_number,
caller_id_name,
dialed_number,
count(*) NumberOfCalls,
round(sum(duration_seconds)/60,2) CallDurationMin
FROM kazoo_cdr_rpt
WHERE cdr_date_time > '20-08-2017'
AND cdr_date_time < 24-08-2017
AND length(caller_id_number) < 5
AND direction = "outbound"
GROUP BY dialed_number;
当我在postgres中执行上述查询时,它会收到错误
round(sum(durati... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
答案 0 :(得分:0)
如果您的持续时间为varchar
,则必须将其转换为数字:
SELECT caller_id_number,
caller_id_name,
dialed_number,
count(*) NumberOfCalls,
round(sum(CAST(duration_seconds as numeric))/60,2) CallDurationMin
FROM kazoo_cdr_rpt
WHERE cdr_date_time > '20-08-2017'
AND cdr_date_time < '24-08-2017'
AND length(caller_id_number) < 5
AND direction = "outbound"
GROUP BY caller_id_number, caller_id_name, dialed_number;