我在表中有以下信息,如果两个日期之间的差异> = 1,我想检索计数。
Id testdate exdate
1 20120502 20120501 --> This should included, because diff is 1
2 20120601 20120601 --> This should not included, because diff is 0
3 20120704 20120703 --> This should included, because diff is 1
4 20120803 20120802 --> This should included, because diff is 1
根据以上数据,我的选择计数应该返回 3。
我正在尝试以下操作,但没有给出任何结果:
select count(to_char(testdate,'YYYYMMDD')-to_char(exdate,'YYYYMMDD')) from test ;