Select 
(Select IsNull(Count(*),0) from INFO Where A=1)  As N'A等于1的个数',
(Select IsNull(Count(*),0) from INFO Where B=0)  As N'B等于0的个数'

解决方案 »

  1.   

    (select count(*) from info where a=1) union (select count(*) from test where b=0)
      

  2.   

    select count(*) from info where a=1 union all select count(*) from info where b=0
      

  3.   

    select 
    sum(case where a=1 then 1 else 0 end) as A為1的個數﹐
    sum(case where b=0then 1 else 0 end) as B為0的個數
    from info
      

  4.   

    hopewell_Go,这样写好像会出错诶!
      

  5.   

    --建立测试环境
    Create table INFO
    (A Int,
     B Int)
    GO
    --插入数据
    Insert INFO Values(1,2)
    Insert INFO Values(2,0)
    Insert INFO Values(3,1)
    Insert INFO Values(1,0)
    Insert INFO Values(2,0)
    GO
    --测试
    Select 
    (Select IsNull(Count(*),0) from INFO Where A=1)  As N'A等于1的个数',
    (Select IsNull(Count(*),0) from INFO Where B=0)  As N'B等于0的个数'
    GO
    --删除测试环境
    Drop table INFO
    --结果
    /*
    A等于1的个数 B等于0的个数
    2 3
    */
      

  6.   

    没有,没有,这样很好!^_^!谢谢了哦!
    我的意思是“select 
    sum(case where a=1 then 1 else 0 end) as A為1的個數﹐
    sum(case where b=0then 1 else 0 end) as B為0的個數
    from info

    这个好像会出错!不是你写的那个