如果是没有规则的话,就case when穷举

解决方案 »

  1.   

    试了一下,不是我想要的哦,我想要的是如果是连续的数据比如1,2,3,4,5 那就是1-5显示,如果不是连续的比如12,那就显示为12 ,比如17,18,19,20又是连续的,那就显示为17-20  实例: create table T(ID int)
     select '1' union all
     select '2' union all 
     select '3' union all
     select '4' union all
     select '5' union all
     select '12' union all
     select '17' union all
     select '18' union all
     select '19' union all
     select '20' union all
     select '25' union all