0

我有一个查询,其中减去两个日期,但出现错误。这是查询

select LOSA_APP.app_ref_no AS "App.Ref.No.", 
       CODE_BRANCH.branch_name AS "Business Unit",
       ...,
       :endDate - LOSA_APP_Z.li_dt AS "Day Count",.
       ...
 from losa_app LOSA_APP
INNER JOIN code_branch CODE_BRANCH
   ON LOSA_APP.attend_branch = CODE_BRANCH.branch_id
....
where LOSA_APP.app_status='A'; -- Application Status in {‘accepted’} 

但我收到错误

ORA-00932: inconsistent datatypes: expected CHAR got DATE
00932. 00000 -  "inconsistent datatypes: expected %s got %s"
*Cause:    

我做错了什么?

4

1 回答 1

1

:endDate绑定变量是错误的原因。尝试:endDate使用函数将值显式转换为日期数据类型的值to_date。例如:

 ....

 to_date(:endDate, 'dd.mm.yyyy') - LOSA_APP_Z.li_dt AS "Day Count",

 ....
于 2012-11-30T06:36:12.280 回答