UNION 内部的 SELECT 语句必须拥有相同数量的列。列也必须拥有相似的数据类型。同时,每条 SELECT 语句中的列的顺序必须相同。
UNION ALL 命令和 UNION 命令几乎是等效的,不过 UNION ALL 命令会列出所有的值。意思就是相同字段有相同值,就会重复显示。
select prjcode,jgdm, count(1) from ( (select prjcode,jgdm from d_file9_0001 where status=0 and attr=1 ) union all (select prjcode,jgdm from d_file10_0001 where status=0 and attr=1 ) union all (select prjcode,jgdm from d_file11_0001 where status=0 and attr=1 ) ) t group by prjcode,jgdm
时间: 2024-09-30 14:23:52