我有下面的查询,其中日期是硬编码的。我的目标是删除编码日期;查询运行时应提取上个月的数据。
select count(distinct switch_id)
from [email protected] /cdn-cgi/l/email-protection
where dealer_name = 'XXXX'
and TRUNC(CREATION_DATE) BETWEEN '01-AUG-2012' AND '31-AUG-2012'
我应该使用sysdate-15
功能是为了那个?
稍微修改一下本的查询,
select count(distinct switch_id)
from [email protected] /cdn-cgi/l/email-protection
where dealer_name = 'XXXX'
and creation_date between add_months(trunc(sysdate,'mm'),-1) and last_day(add_months(trunc(sysdate,'mm'),-1))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)