select a.workitemid as workitemid,a.testSort as testSort from examinee a
where testplanid=56 and testtype like '%_1_%' and theorytestRoom is not null
group by a.workitemid,a.testSort,a.theoryspotid,a.theorytestRoom 
order by  a.workitemid,a.testSort,a.theoryspotid,a.theorytestRoom查出结果是3 01
3 01
3 01
3 01
3 01
3 01
3 02
3 02
3 02
3 02
我现在要怎么修改可以统计出3 01 6
3 02 4
这种结果  最后加位总数

解决方案 »

  1.   

    select a,b count(a) from tb group by a,b
      

  2.   

    select a.workitemid as workitemid,a.testSort , count(*) as number from examinee a
    where testplanid=56 and testtype like '%_1_%' and theorytestRoom is not null
    group by a.workitemid,a.testSort,a.theoryspotid,a.theorytestRoom ,a.testSort
    order by  a.workitemid,a.testSort,a.theoryspotid,a.theorytestRoom
      

  3.   

    select workitemid,testSort,count(testSort)num from tb group by workitemid,testSort
      

  4.   

    select a.workitemid as workitemid,a.testSort as testSort from examinee a
    where testplanid=56 and testtype like '%_1_%' and theorytestRoom is not null
    group by a.workitemid,a.testSort
    order by  a.workitemid,a.testSort
      

  5.   

    select a.workitemid as workitemid,a.testSort as testSort,count(testSort)as num from examinee a
    where testplanid=56 and testtype like '%_1_%' and theorytestRoom is not null
    group by a.workitemid,a.testSort,a.theoryspotid,a.theorytestRoom 
    order by  a.workitemid,a.testSort,a.theoryspotid,a.theorytestRoom
      

  6.   

    select a.workitemid as workitemid,a.testSort as testSort count(a.workitemid) from examinee a
    where testplanid=56 and testtype like '%_1_%' and theorytestRoom is not null
    group by a.workitemid,a.testSort
    order by  a.workitemid,a.testSort
      

  7.   

    select
     a.workitemid as workitemid,a.testSort , count(*) as number 
    from
     examinee a
    where
     testplanid=56 and testtype like '%_1_%' and theorytestRoom is not null
    group by
     a.workitemid,a.testSort,a.theoryspotid,a.theorytestRoom ,a.testSort
    order by
      a.workitemid,a.testSort,a.theoryspotid,a.theorytestRoom
      

  8.   

    select workitemid , testSort , count(1) from
    (
    select a.workitemid as workitemid,a.testSort as testSort from examinee a
    where testplanid=56 and testtype like '%_1_%' and theorytestRoom is not null
    group by a.workitemid,a.testSort,a.theoryspotid,a.theorytestRoom 
    ) t
    group by workitemid , testSort
    order by workitemid , testSort
      

  9.   

    select workitemid , testSort , count(1) from
    (
    select a.workitemid as workitemid,a.testSort as testSort from examinee a
    where testplanid=56 and testtype like '%_1_%' and theorytestRoom is not null
    group by a.workitemid,a.testSort,a.theoryspotid,a.theorytestRoom 
    ) t
    group by workitemid , testSort
    order by workitemid , testSortselect m.* , (select count(1) from 
    (
    select a.workitemid as workitemid,a.testSort as testSort from examinee a
    where testplanid=56 and testtype like '%_1_%' and theorytestRoom is not null
    group by a.workitemid,a.testSort,a.theoryspotid,a.theorytestRoom 
    ) n where n.workitemid = m.workitemid and n.testSort = m.testSort) from
    (
    select a.workitemid as workitemid,a.testSort as testSort from examinee a
    where testplanid=56 and testtype like '%_1_%' and theorytestRoom is not null
    group by a.workitemid,a.testSort,a.theoryspotid,a.theorytestRoom 
    ) m
    order by m.workitemid , m.testSort
      

  10.   


    上面直接加COUNTT()的都不对 
    只有8楼的可以查询出 不知道还有没有别的方法
      

  11.   


    上面直接加COUNTT()的都不对 
    只有8楼的可以查询出 不知道还有没有别的方法
      

  12.   

    select workitemid,testSort,count(testSort)num from tb group by workitemid,testSort