我这有两张表 表A 和表B
select count(*) from A where aaa=0
select count(*) from B where bbb=0
要用一条sql语句查出这两个sql语句的结果总和
select count(*) from A where aaa=0
select count(*) from B where bbb=0
要用一条sql语句查出这两个sql语句的结果总和
select count(*) from B where bbb=0
*
from
(
select count(*) from A where aaa=0 +select count(*) from B where bbb=0
)t
(select count(*) from B where bbb=0)
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
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