select Target.T_Name,Target.T_Detail,count(tmp.[ID]) from
Target inner join
(
select A.A_ID [ID],A.A_Name [Name] from A
union all
select B.B_ID [ID],B.B_Name [Name] from B
union all
select C.C_ID [ID],C.C_Name [Name] from C
) tmp
group by Target.T_Name,Target.T_Detail
Target inner join
(
select A.A_ID [ID],A.A_Name [Name] from A
union all
select B.B_ID [ID],B.B_Name [Name] from B
union all
select C.C_ID [ID],C.C_Name [Name] from C
) tmp
group by Target.T_Name,Target.T_Detail
(select count(*) from 表B where B_name = a.T_name)+
(select count(*) from 表C where C_name = a.T_name) as Num
from Target a
Target inner join
(
select A.A_ID [ID],A.A_Name [Name] from A
union all
select B.B_ID [ID],B.B_Name [Name] from B
union all
select C.C_ID [ID],C.C_Name [Name] from C
) tmp on tmp.[Name] = Target.T_Name
group by Target.T_Name,Target.T_Detail
Target join
(
select A.A_Name [Name] from A
union all
select B.B_Name from B
union all
select C.C_Name from C
) tmp on Target.t_name=tmp.a_name
group by Target.T_Name,Target.T_Detail
Target a join
(
select A.A_ID ID,A.A_Name [Name] from A
union all
select B.B_ID,B.B_Name from B
union all
select C.C_ID,C.C_Name from C
) b
on a.T_Name=b.[Name]
group by a.T_Name,a.T_Detail
((
select A_Name from A
union all
select B_Name from B
union all
select C_Name from C
) b
join Target a on a.a.T_Name=b.A_Name
) tem
group by T_Name,T_Detail