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.
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')