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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠