2014年8月11日 星期一

mssql count union all

參考引用來源:SQL: Combine Select count(*) from multiple tables
--

SELECT SUM(A)
FROM
(
    SELECT 1 AS A
    UNION ALL
    SELECT 1 AS A
    UNION ALL
    SELECT 1 AS A
    UNION ALL
    SELECT 1 AS A
) AS B




select sum(counts) from (
select count(1) as counts from aa
union all
select count(1) as counts from bb
) as cc

沒有留言:

張貼留言