有一张表
ID,NAME,STATUS
现在我要查出ID,NAME,和其中STATUS为0的记录数和STATUS为1的记录总数

解决方案 »

  1.   

    select ID,NAME from table_name where STATUS=0 or STATUS=1
      

  2.   

    select STATUS, count(STATUS) from table_name where STATUS=0 or STATUS=1
    group by STATUS
      

  3.   

    假设status为0通过,为1不通过
    我现在要这样的记录
    id  name   通过的总数  不通过的总数
    1    fff       5           2
    你给的SQL不太直接
      

  4.   

    select ID,NAME,COUNT(DECODE(STATUS,1,1)) PASS,COUNT(DECODE(STATUS,0,1)) UNPASS
     from table_name
    GROUP BY ID,NAME