字段1
1111
1024
10240001
10240002
102400020001
102400020002
1030
10300001
有一数据表,记录如上编码分层级,如何将最末级的编码数据取出?结果为取出1111,102400020001,102400020002,10300001)
用SQL

解决方案 »

  1.   

    create table #t(a char(20))
    insert into #t(a) 
    select 1111 
    union all
    select 1024 
    union all
    select 10240001 
    union all
    select 10240002 
    union all
    select 102400020001 
    union all
    select 102400020002 
    union all
    select 1030 
    union all
    select 10300001 select * from #t where a not in (select t1.a from #t t1 inner join #t t2  on t1.a<>t2.a and t1.a=left(t2.a,len(t1.a)) )  
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 
    http://feiyun0112.cnblogs.com/
      

  2.   

    能达到效果就行,feiyun0112谢谢,通过