ÏÖÔÚÎÒÏë´ÓÕâÁ½¸ö±íÖеõ½½á¹û ºÅ ºÅͳ¼Æ 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