问题代码
select * from om_exp a, om_exp_item b
where a.exp_no = b.exp_no and a.exp_type = 'OM' and a.fast_flag = '0' and
a.updt_name = 'BKLOC' and
a.updt_date between
to_date(to_char(sysdate - &1, 'yyyymmdd') || ' 00:00:00',
'yyyymmdd HH24:Mi:SS') and
to_date(to_char(sysdate - &1, 'yyyymmdd') || ' 23:59:59',
'yyyymmdd HH24:Mi:SS')
group by to_date(to_char(a.updt_date, 'yyyymmdd'), 'yyyymmdd'),
这个查日期,如果日期格式不对,有空格等是查询不到的,比如
select * from om_exp a where a.updt_date like '2011-11-09%' 可以查到
select * from om_exp a where a.updt_date='2011-11-09' 不可以查到
select * from om_exp a where a.updt_date='2011-11-10' 可以查到
解决办法为
select * from om_exp a where a.updt_date>='2011-11-09' and a.updt_date<='2011-11-10'
查询到的就为9号一天的