select * from test where right(aaa,4)='0000'

解决方案 »

  1.   

    select count(*) from test a ,部门表 b where substring(a.部门编码,1,4)=b.一级部门编码 group by b.一级部门编码
      

  2.   

    select b.一级部门编码,count(*) from test a ,部门表 b where substring(a.部门编码,1,4)=b.一级部门编码 group by b.一级部门编码
      

  3.   

    用:where 编号 like '01%'树型 参考:
    http://expert.csdn.net/Expert/topic/1375/1375432.xml?temp=.8570978
      

  4.   

    select count(*) from test 
    where 编号 like '01%'
      

  5.   

    where 编号 like '01%'   
      

  6.   

    select 部门,count(*) as cnt from [table] group by left(部门代码,2)
      

  7.   

    错了  是
    select (select  部门 from [table] t where t.部门代码=left(部门代码,2)+'0000') as 部门,count(*) as cnt from [table] group by left(部门代码,2)
      

  8.   

    又写漏了 瞧我这水平!select (select  部门 from [table] t where t.部门代码=left([table].部门代码,2)+'0000') as 部门,count(*) as cnt from [table] group by left(部门代码,2)