Sql语句统计多表个数并求和

时间:2024-01-31 08:33:28
SELECT COUNT(1) FROM 

((SELECT BaseID FROM dbo.Life_cheliang WHERE  BaseCreateDate BETWEEN \'2015-6-5\' AND \'2015-6-11\')
UNION
(SELECT BaseID FROM dbo.Life_fangchan WHERE  BaseCreateDate BETWEEN \'2015-6-5\' AND \'2015-6-11\')
UNION
(SELECT BaseID FROM dbo.Life_tiaozao WHERE  BaseCreateDate BETWEEN \'2015-6-5\' AND \'2015-6-11\')
UNION
(SELECT BaseID FROM dbo.Life_shenghuo WHERE  BaseCreateDate BETWEEN \'2015-6-5\' AND \'2015-6-11\')
UNION
(SELECT BaseID FROM dbo.Life_zhaopin WHERE  BaseCreateDate BETWEEN \'2015-6-5\' AND \'2015-6-11\')
UNION
(SELECT BaseID FROM dbo.Life_chongwu WHERE  BaseCreateDate BETWEEN \'2015-6-5\' AND \'2015-6-11\')
UNION
(SELECT BaseID FROM dbo.Life_shangwu WHERE  BaseCreateDate BETWEEN \'2015-6-5\' AND \'2015-6-11\')
UNION
(SELECT BaseID FROM dbo.Life_peixun WHERE  BaseCreateDate BETWEEN \'2015-6-5\' AND \'2015-6-11\')
UNION
(SELECT BaseID FROM dbo.Life_piaowu WHERE  BaseCreateDate BETWEEN \'2015-6-5\' AND \'2015-6-11\')
) test