选择最大或最晚日期时出错

时间:2018-04-18 06:45:07

标签: vb.net oracle

我想显示具有最新日期的详细信息。但我有一个问题。它说'#34; Oracle.DataAccess.Client.OracleException:ORA-00923:找不到FROM关键字"有人能帮我吗?

以下是查询:

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;
提前,TQ提前。 = P

1 个答案:

答案 0 :(得分:0)

您的查询看起来不错;但是,我删除了TO_CHAR电话,似乎没必要&amp;不当。此外,根据您使用的工具,两者之间的空行可能会导致问题。尝试使用这样的查询:

  SELECT DISTINCT ccsmasterlistrevno,
                  ccsrevcontent,
                  ccspreparedrev,
                  ccsreveffectivedate
    FROM ccs2_tbl_masterlist
   WHERE     ccsequipmentdpmt = :dpmt
         AND ccsmasterlistrevno <= :revno
         AND ccsreveffectivedate =
                (SELECT MAX (ccsreveffectivedate) FROM ccs2_tbl_masterlist)
ORDER BY ccsmasterlistrevno DESC;