Skip to content
Advertisement

Missing keyword Oracle SQL

I have this SQL query and I am getting “MISSING KEYWORD” error.

SELECT SUM(CASE WHEN DUECD = 'PRI' THEN DUEAMT ELSE '0') AS LATESTPRIN, SUM(CASE WHEN DUECD != 'PRI' THEN DUEAMT ELSE '0') AS LATESTINT FROM LLDUEDET WHERE STARTDT = TO_DATE('2020-01-20', 'YYYY-MM-DD')

What is my mistake? I have been trying to debug this.

Advertisement

Answer

Adding an END inside the parenthesis should be enough:

SELECT
  SUM(CASE WHEN DUECD = 'PRI' THEN DUEAMT ELSE '0' END) AS LATESTPRIN,
  SUM(CASE WHEN DUECD != 'PRI' THEN DUEAMT ELSE '0' END) AS LATESTINT
FROM
  LLDUEDET
WHERE
  STARTDT = TO_DATE('". $LatestDate ."', 'YYYY-MM-DD')
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement