SELECT count(*) FROM ccs_comp_claim t, ccs_loan t2WHERE t.ref_nbr = t2.ref_nbr AND t.finish_date is null AND t.cooperator_id = 'DYBANK' AND t2.union_insu_case_date <![CDATA[ < ]]> #{countDate,jdbcType=TIMESTAMP},如上sql的countDate为参数,要实现union_insu_case_date小于countDate加1天
时间: 2023-11-28 13:48:07 浏览: 77
可以使用DATEADD函数来实现:
```
SELECT count(*)
FROM ccs_comp_claim t, ccs_loan t2
WHERE t.ref_nbr = t2.ref_nbr
AND t.finish_date is null
AND t.cooperator_id = 'DYBANK'
AND t2.union_insu_case_date < DATEADD(day, 1, #{countDate,jdbcType=TIMESTAMP})
```
这里使用了DATEADD函数来将countDate加上1天,然后与union_insu_case_date进行比较。
相关问题
SELECT count(*) FROM ccs_comp_claim t, ccs_loan t2WHERE t.ref_nbr = t2.ref_nbr AND t.finish_date is null AND t.cooperator_id = 'DYBANK' AND t2.union_insu_case_date <![CDATA[ < ]]> #{countDate,jdbcType=TIMESTAMP},如上sql的countDate为参数,要实现union_insu_case_date加1天小于countDate
你可以使用DATEADD()函数来实现将union_insu_case_date加1天的操作,然后再将其与countDate进行比较,如下所示:
```
SELECT count(*)
FROM ccs_comp_claim t, ccs_loan t2
WHERE t.ref_nbr = t2.ref_nbr
AND t.finish_date is null
AND t.cooperator_id = 'DYBANK'
AND DATEADD(day, 1, t2.union_insu_case_date) < #{countDate,jdbcType=TIMESTAMP}
```
在上述代码中,`DATEADD(day, 1, t2.union_insu_case_date)`表示将`t2.union_insu_case_date`加1天。然后将其与`#{countDate,jdbcType=TIMESTAMP}`进行比较来完成你所需的功能。
阅读全文