Oracle SQL where子句中带有日期过滤器的无效数字

时间:2015-01-19 18:32:24

标签: sql oracle date where-clause

使用Oracle SQL,我的查询收到此错误:

ORA-01722:无效的号码 01722. 00000 - "无效号码"

我使用两个表来从请求的事务表中获取最大日期和最小日期。没有线" AND mgr_min.create_date> to_date(' 01-01-15',' MM-DD-YY')"它似乎返回了我需要的结果。但是当我尝试根据创建请求的日期进行过滤时...我得到了错误。这是查询:

SELECT mr.accessor_id,
   mrs.status_description,
   mso.option_name,
   CAST(mgr_max.create_date AS TIMESTAMP) AS "Action Date",
   mgr_max.detail_comment AS "Comment",
   mgr_min.create_date AS "Date Created"
FROM moca_request mr,
   moca_request_status mrs,
   moca_system_option mso,
   moca_system ms,
 (SELECT mrt.request_id, mrt.status_id, mrt.approver_id, mrt.create_date, mrt.detail_comment
  FROM moca_request_transaction mrt
  INNER JOIN (
    SELECT request_id, MAX(create_date) AS maxdate
    FROM moca_request_transaction
    GROUP BY request_id) mrt2
    ON mrt.request_id = mrt2.request_id AND mrt.create_date = mrt2.maxdate) mgr_max,
  (SELECT mrt3.create_date, mrt3.request_id
   FROM moca_request_transaction mrt3
   INNER JOIN (
    SELECT request_id, MIN(create_date) AS createdate
    FROM moca_request_transaction
    GROUP BY request_id) mrt4
    ON mrt3.request_id = mrt4.request_id AND mrt3.create_date = mrt4.createdate) mgr_min      
WHERE mgr_max.request_id = mr.request_id
AND   mgr_max.status_id = mrs.status_id
AND   mgr_min.request_id = mr.request_id
AND   mso.option_id = mr.option_id
AND   ms.system_id = mr.system_id
AND   mgr_min.create_date > to_date('01-01-15', 'MM-DD-YY')

0 个答案:

没有答案