SYNTAX_ERROR: line 1:20: Column 'sysdate' cannot be resolved

0

SELECT trunc(avg(sysdate - TRUNC(PZD.ORDER_DATE))) DATE_DIFF FROM PZDTORBK PZD WHERE PZD.ORDER_DATE > cast('2021-01-01'as timestamp)

已提問 2 年前檢視次數 847 次
4 個答案
0

sysdate is a function. Try sysdate() instead.

已回答 2 年前
  • I tried it, but it did not work. I am still getting the same error message. Thank you

0

Sorry, I was wrong. Athena uses current_date. Try that.

已回答 2 年前
0

You also might need to use date_diff for subtracting the two dates like in this post: https://stackoverflow.com/questions/58326786/athena-datediff

已回答 2 年前
0

Please refer to this documentation page for a list of all Athena functions, and specifically to this trino documentation page for the Date & Time Function.

Your Query should read as:

SELECT  avg(date_diff('day',PZD.ORDER_DATE,current_date)) as MY_DATE_DIFF 
FROM PZDTORBK PZD 
WHERE PZD.ORDER_DATE > cast('2021-01-01'as timestamp)

Enter image description here

hope this helps

AWS
專家
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南