有一个表(表名为partnoybb)的数据如下;
partno     sectionno     materspec
8797120B0    01          0.5                           
8797120B0     02          1080Y                         
8797120B0     03          1080Y                         
8797120B0    04          2/3L                          
8797120B0     05          7628Y                         
8797120B0     06          7628Y                         
8797120B0     07          4/5L                          
8797120B0     08          7628Y                         
8797120B0    09          7628Y                         
8797120B0     10          6/7L                          
8797120B0     11          1080Y                         
8797120B0     12          1080Y                         
8797120B0     13          0.5 
现在我想统计 字段materspec的数据:0.5到2/3L之间,2/3L到4/5L之间,4/5L到6/7L之间 ,6/7L到0.5之间的各个行数,也就是第一行到与他的下一个带'/'且最后一个字符是'L'的之间,带'/'且最后一个字符是'L' 和带'/'且最后一个字符是'L'之间,带'/'且最后一个字符是'L'与最后一行之间的各个行数.
希望得到的结果如下:2
2
2
2
如不明白可以提出来.

解决方案 »

  1.   

    select materspec,ssectionno-(select max(a.sectionno) from  partnoybb a where a.materspec like '%/%L' or a.sectionno = '01') from partnoybb b where b.materspec like '%/%L' or b.sectionno = '01';
      

  2.   

    bzszp(SongZip) ,我还有一个条件就是partno='8797120B0',请问怎么写啊?
      

  3.   

    select a.G,(
      select count(*) 
      from partnoybb t 
      where  and partno='8797120B0' 
      and t.sectionno > a.a and t.sectionno < a.b  --and t.sectionno between a.a and a.b
      )C
    from (
      select row_number()over(order by ID) G,
        sectionno a, lead(sectionno,1,'99')over(order by sectionno) b
      from (
    --???    select '00' sectionno from dual unoin all  
        select sectionno
        from  partnoybb
        where (materspec like '%/%L' or materspec ='0.5') and partno='8797120B0'
        )a
      )a
    ;