Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I want to display some details based on the latest date. But, I have problem with it. It say that "Oracle.DataAccess.Client.OracleException: ORA-00923: FROM keyword not found where expected"

What I have tried:

Below are the query:

SELECT DISTINCT CCSMASTERLISTREVNO, CCSREVCONTENT, CCSPREPAREDREV,
CCSREVEFFECTIVEDATE

FROM CCS2_TBL_MASTERLIST

WHERE CCSEQUIPMENTDPMT = :DPMT

AND CCSMASTERLISTREVNO <= :REVNO

AND CCSREVEFFECTIVEDATE =

( SELECT MAX(TO_CHAR(CCSREVEFFECTIVEDATE,'dd/MM/yyyy'))

FROM CCS2_TBL_MASTERLIST )

ORDER BY CCSMASTERLISTREVNO DESC;
Posted
Updated 17-Apr-18 21:13pm

SQL
( SELECT MAX(TO_CHAR(CCSREVEFFECTIVEDATE,'dd/MM/yyyy'))<- extra ) here

FROM CCS2_TBL_MASTERLIST ) <- this is the end of the SELECT

You have an extra closing parenthesis on the first line above.

And why are you converting your dates to character strings to find the maximum value?
 
Share this answer
 
To add to what Richard says: when you compare dates as strings, you use a string comparison. Which means that the two strings are examined character by character and the result of the whole comparison is based on the first different pair of characters found.
Which in your case means that 11/01/2018 comes before 12/01/1977 and after 01/01/2048

You must store and compare dates as dates, not strings - or you will get some very odd seeming results.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900