select 表1.*,sysdate-to_date(to_char(表1.入库日期,'dd-mm-yy')||表1.入库时间,'dd-mm-yyhh24:mi') 时间差,表2.*
from 表1,表2 where 表1.ID=表2.ID(可以查询两表信息)
请问如果我想查询23小时以前的这两个表里的数据如何改?我这样写
select 表1.*,sysdate-to_date(to_char(表1.入库日期,'dd-mm-yy')||表1.入库时间,'dd-mm-yyhh24:mi') 时间差,表2.*
from 表1,表2 where to_date(to_char(表1.入库日期,'dd-mm-yy')||表1.入库时间,'dd-mm-yyhh24:mi')<=sysdate-24/24 and 表1.ID=表2.ID
可是显示ERROR:
ORA-01858: a non-numeric character was found where a numeric was expected
no rows selected
各位老师给看看,

解决方案 »

  1.   

    select storer.storerkey,
           sysdate - to_date(to_char(storer.adddate, 'dd-mm-yy') ||'23:00',
                             'dd-mm-yy hh24:mi') 时间差,
           sku.sku
      from storer,sku
     where to_date(to_char(storer.adddate, 'dd-mm-yy') || '23:00',
                   'dd-mm-yy hh24:mi')<= sysdate - 24 / 24
       and storer.storerkey=sku.storerkey 这是我按照你的写法写的,run不报错.