Getting max value from a Date column in Oracle using max()

Viewed 18

I am trying to query the latest date from table with a column DATE.

My expression is as follow: SELECT MAX(DATE) FROM table_name;

I received back error: ORA-00936: missing expression 00936. 00000 - "missing expression" *Cause:
*Action:

Any idea what is the issue? please help.

1 Answers

DATE is a reserved word and cannot be used as an unquoted identifier as the SQL engine expects it to be either a data-type or as part of a date literal such as DATE '1970-01-01'. In your case, the SQL engine expects DATE to be followed by the literal of the date-literal (e.g. '1970-01-01') but that does not happen which is why it complains about a missing expression.

If you have a column named DATE then you should:

  1. Change it to a different name; or

  2. If that is not possible, always use a quoted identifier whenever you refer to the column (which requires double quotes around the identifier and the correct case to be used).

    SELECT MAX("DATE") FROM table_name;
    
Related