我在oracle数据库上运行。我想找到所有在25岁前接受治疗的受助者。我知道至少有500个,但我得到的结果是0.显然,我的查询是错误的。所以我认为问题在于我减去日期的方式。他们都是表格中的日期类型。从我看到的情况来看,应该可以只减去两个日期? 有人写道他们使用DATEDIFF,但这对我不起作用。从两个日期计算年份
select count(*) FROM V_Persons
where exists(select * from res_tx res, recipient rec, Treatment tr
where (tr.TREAT_DATE - rec.DATE_OF_BIRTH) < 25
and rec.ident = res.ident
and rec.ident = tr.ident)
你可以只减去两个日期,但在甲骨文的日期基本arithmatic给出的答案在天。 – OTTA