现在我想从这两个表中得到结果 号 号统计 1 2 2 3 3 1 SQL code: SELECT ID,COUNT(1) from ( SELECT COL1 AS 'ID' from A UNION ALL SELECT COL1 AS 'ID' from B ) T GROUP BY ID
select c.号,count(1) from (select 号 from A union select 号 from b ) c group by c.号 UNION 就去重复了,用UNION ALL SQL code: select t.号,count(1) as 号统计 from (select 号 from A union select 号 from b )t group by t.号
SQL code: SELECT ID from (SELECT ID from A UNION ALL SELECT ID from B)AS T GROUP BY ID
-- my name is sinpoal
--> 建表 create table a( id int) insert a select 1 union all select 1 union all select 2