我这有两张表 表A 和表B
select count(*) from A where aaa=0
select count(*) from B where bbb=0
要用一条sql语句查出这两个sql语句的结果总和

解决方案 »

  1.   

    select count(*) from A where aaa=0 +
    select count(*) from B where bbb=0
      

  2.   

    select
      *
    from
      (
       select count(*) from A where aaa=0 +select count(*) from B where bbb=0
      )t
      

  3.   

    select (select count(*) from A where aaa=0 ) +
    (select count(*) from B where bbb=0)
      

  4.   

    select (select count(*) from A where aaa=0)+(select count(*) from B where bbb=0)
      

  5.   


    declare @CountA int
    declare @CountB intset @CountA=(select count(*) from A where aaa=0)
    set @CountB=(select count(*) from B where bbb=0)select @CountA+@CountB as Total
      

  6.   


    select sum(a) from (
    select count(*) as a from A where aaa=0
    union all
    select count(*) as b from B where bbb=0
    ) T