这个表我想查出 过车时间相差10S内的车牌号列表 ,并且只显示满足这个条件次数大于2 的数据,我这个 不写 rownum <200 会特别慢。 外联的话不加限制条件是两个表内容乘积数量,所以肯定不能这么写。
EMM。
总思路 是查出 一天时间段内 出现间隔小于设置的间隔 的情况大于 设置的阈值 算同行,最终要查的数据是 同行对象的个数, 开始同行时间 最后同行时间 同行被捕获的次数 (即那个小于间隔的那个情况个数)。

解决方案 »

  1.   

    对列有计算,肯定会慢,表结构和索引情况都说一下,贴一下 DLL 。
      

  2.   

    分页和不分页当然会有性能差异,把SQL也贴出来吧,最好还有执行计划
      

  3.   

    好的提问方式应该是:
    1.贴上表结构:如果HK_CLKK表结构就是你上面的截图,那就不需要了。
    2.附上建表语句和测试语句,即:Create语句+insert语句,毕竟与人方便,就是给己方便。
    3.说明下要实现的效果,最好是有图像展示效果。
      

  4.   

    select cphm ,count(*) from (
    select 
    cphm,
    lag(to_date(gcsj)) over(partition by cphm order by to_date(gcsj) desc)-to_date(gcsj) d_minus
    from hk_clkk
    ) t1
    where d_minus*24*60*60<10
    group by cphm
    having count(*)>2;
      

  5.   

    select cphm ,count(*) from (
    select 
    cphm,
    lag(to_date(gcsj,'yyyy-mm-dd hh24:mi:ss')) over(partition by cphm order by to_date(gcsj,'yyyy-mm-dd hh24:mi:ss') desc)-to_date(gcsj,'yyyy-mm-dd hh24:mi:ss') d_minus
    from hk_clkk
    ) t1
    where d_minus*24*60*60<10
    group by cphm
    having count(*)>2;刚刚 to_date 格式漏了,这个写法的话 表扫一遍,没测性能,可以试试