我有一个SQL查询,看起来像这样:
select name, count (*) from Results group by name order by name
从归档结果表加载的另一个相同,但字段相同。
select name, count (*) from Archive_Results group by name order by name
如何在一个查询中将两者结合?(因此group by仍然可以正常运行)。我尝试了所有的联合,但是没有用。我想念什么?
SELECT tem.name, COUNT(*) FROM ( SELECT name FROM results UNION ALL SELECT name FROM archive_results ) AS tem GROUP BY name ORDER BY name