本帖最后由 lziyanl 于 2012-11-22 21:07:20 编辑

解决方案 »

  1.   

    select * from
    (select count(*) AS counts1 from A where A.state = 1) a,
    (select count(*) AS counts2 from A where A.state2 = 0) b
      

  2.   

    select sum(if(state = 1,1,0)) as counts1,sum(if(state2 = 1,0,1)) as counts2
    from A
      

  3.   


    select count(case when state=1 then 1 else 0 end) as num1,
    count(case when state=0 then 1 else 0 end) as num2
    from A