-- 把子查询做成一个 function 比较方便。 -- PS : TSQL 是 SQL Server 。 select SUM(rn) from ( select COUNT(*) as rn from t1 where id = 100 union all select COUNT(*) from t2 where id = 100 union all select COUNT(*) from t3 where id = 100 union all select COUNT(*) from t4 where id = 100 )
-- 把子查询做成一个 function 比较方便。
-- PS : TSQL 是 SQL Server 。
select SUM(rn) from (
select COUNT(*) as rn from t1 where id = 100
union all
select COUNT(*) from t2 where id = 100
union all
select COUNT(*) from t3 where id = 100
union all
select COUNT(*) from t4 where id = 100
)