本帖最后由 l270545504 于 2014-05-04 11:16:20 编辑

解决方案 »

  1.   

    建议楼主用用分析函数lead,把第二行的 开始时间"2014-6-9",作为一个列偏移到第一行中。然后,就可以用结束时间和偏移的开始时间继续比较了。     
      

  2.   

    可否写出代码?
    多个不同的ITEM有的ITEM是3条记录 甚至更多记录
      

  3.   


    select t1.num,t1.bsh01,t2.bsh01 from (select rownum as num,bshdate,bsh42,bsh01 from cshfjnsz.bsh_file
    where bsh42 is not null) t1,(select rownum as num,bshdate,bsh42,bsh01 from cshfjnsz.bsh_file
    where bsh42 is not null) t2
    where t1.bsh42 between t2.bshdate and t2.bsh42
    and t1.num<100
    order by t1.num
    這個是我查詢的,日期重合的太多(bshdate,bsh42),加了個限制and t1.num<100
    ,你可以換成你的item。
      

  4.   

    谢谢 
    我用lead 解决了