试一试这个SELECT COUNT(strCpUid) AS num1, StrServiceid,count(case state when 0 then 1 eles null end) as num0,
count(case state when 1 then 1 eles null end) as num1,
count(case state when 2 then 1 eles null end) as num0
FROM T_CP_DZ_USER 
GROUP BY StrServiceid  ORDER BY StrServiceid

解决方案 »

  1.   

    SELECT COUNT(strCpUid) FROM T_CP_DZ_USER c where 0=0  and strDateTime>='040418135931' and strDateTime<='040419135931' and StrServiceid = T_CP_DZ_USER.StrServiceid AND state = 2 AND strCpUid =  'SXTX'
    返回多行,sql错误.
      

  2.   

    SELECT sum(decode(state,0,1,0)) num0,sum(decode(state,1,1,0)) num1,sum(decode(state,2,1,0)) num2 
    FROM T_CP_DZ_USER 
    where 0=0  and strDateTime>='040418135931' and strDateTime<='040419135931' AND strCpUid = 'SXTX'