怎么统计多张表中的数据量
如何统计多张表中的数据量
这样写哪里有错额,如果一张一张统计的话比较麻烦,因为表很多
我是需要把重复的数据也算进去的,可能是语法有问题吧。。。
------解决方案--------------------
- SQL code
select count(*) from ( select * from hs2005.KeepedVoucher union all select * from hs2006.KeepedVoucher union all select * from hs2007.KeepedVoucher union all select * from hs2008.KeepedVoucher union all select * from hs2009.KeepedVoucher union all select * from kjhssj.KeepedVoucher ) t
这样写哪里有错额,如果一张一张统计的话比较麻烦,因为表很多
我是需要把重复的数据也算进去的,可能是语法有问题吧。。。
------解决方案--------------------
- SQL code
select count(*) from ( select * from hs2005..KeepedVoucher union all select * from hs2006..KeepedVoucher union all select * from hs2007..KeepedVoucher union all select * from hs2008..KeepedVoucher union all select * from hs2009..KeepedVoucher union all select * from kjhssj..KeepedVoucher ) t
------解决方案--------------------
- SQL code
select sum(ct) from ( select count(0) ct from hs2005.KeepedVoucher union all select count(0) ct from hs2006.KeepedVoucher union all select count(0) ct from hs2007.KeepedVoucher union all select count(0) ct from hs2008.KeepedVoucher union all select count(0) ct from hs2009.KeepedVoucher union all select count(0) ct from kjhssj.KeepedVoucher ) t
------解决方案--------------------
- SQL code
select (select count(*) from hs2005.KeepedVoucher )+ (select count(*) from hs2006.KeepedVoucher )+ (select count(*) from hs2007.KeepedVoucher )+ (select count(*) from hs2008.KeepedVoucher )+ (select count(*) from hs2009.KeepedVoucher )+ (select count(*) from kjhssj.KeepedVoucher )
------解决方案--------------------
你可以这样做啊,先把这些表的数据的条数列出来,然后在对这些表的数据进行求和就好啦。
select sum(t.c)
from
(
select count(*) c from dbo.xt_tbno
union all
select count(*) c from dbo.xt_user_resource
union all
select count(*) c from dbo.xt_role_resource
union all
select count(*) c from dbo.xt_subsystem
) t