我有一个表totalmodel,里面有一个字段NuitNo,该字段里面的内容有2中形式,YR***,YK***.假设现在有YR123,YRasdf,YR12,YKwed,YK,YKdfg.我现在想通过分组查询得到YK,和YK.这两个大类,即得到的记录条数为2条,请问该怎么办呢?

解决方案 »

  1.   

    select
       left(NuitNo,2),count(1) as num
    from
        totalmodel
    group by
       left(NuitNo,2)
      

  2.   

    select typecode=left(NuitNo,2),cunt(1)
    from tb
    group by left(NuitNo,2)
      

  3.   


    select
       substring(NuitNo,1,2),count(1) as num
    from
        totalmodel
    group by
          substring(NuitNo,1,2)
      

  4.   

    select distinct left(NuitNo,2) from totalmodel
      

  5.   


    select
       left(NuitNo,2),count(1) as num
    from
        totalmodel
    group by
       left(NuitNo,2)
      

  6.   

    select substring(NuitNo,1,2) from totalmodel group by substring(NuitNo,1,2)
      

  7.   


    select subString(NuitNo,1,2) 形式 ,count(NuitNo)记录数 from totalmodel 
    group by subString(NuitNo,1,2)
      

  8.   

    select
       substring(NuitNo,1,2) type_name,count(1) as type_num
    from
        totalmodel
    group by
          substring(NuitNo,1,2)