I have a table with the following structure DEMOTABLE(COL_ID INT,COL_DATE DATE).
Why the following query is giving me an error
Error code 936,SQL state 42000:ORA-00936:missing expression
SELECT MAX(
SELECT TO_CHAR(COL_DATE,'YYYY-MM-DD HH24:MI:SS')
FROM DEMOTABLE WHERE COL_ID IN(1,2,3))
FROM DUAL
It sounds like you want
Generally, you would want to do the
MAXfirst and only then convert the largest date to a string. That is both because you want to use date comparison semantics and because it is cheaper to do the comparison and only do the data type conversion on the one row you’re interested in. You would also want toSELECTfrom the table you’re interested in, not fromDUAL.