查多个相同结构表中某个字段出现的次数方法
假如有20个结构相关的表,字段分别为a,b,c,d,e...t,其中b为人员编号,怎样查询20个表中不同人出现的次数(分组统计记录数),有几种方法?
[解决办法]
select b,count(1) from (select * from aunion allselect * from bUnion allselect * from c...union allselect * from t) Tgroup by b
[解决办法]
select b,count(*) from (select * from 表1union allselect * from 表2Union allselect * from 表3...union allselect * from 表20) tbgroup by b