我来个效率比较差的select count(
            select code distinct from table where type=1),
       count(
            select code distinct from table where type=0)

解决方案 »

  1.   

    select type, count(*) count from (select distinct type, code from table) A
      

  2.   

    不好意思,少写了group by
    select type, count(*) count from (select distinct type, code from table) A group by type
      

  3.   

    呵呵 我自己也捣鼓出来了(和NoThiNg2050(子虚乌有)的答案一样):谢谢两位的回复
    select count(*) as count from (select distinct type,code from table) as tongji  group by type;