select
a.all_data ad, a.act_data aa, (a.act_data / a.all_data* 100) as a_percent
b.all_data bd, b.act_data ba, (b.act_data / b.all_data* 100) as b_percent
from (
select count(id) all_data, (select count(detail) form tb_detail where a......) as act_data from tb_primary where a....
) as a,
(
select count(id) all_data, (select count(detail) form tb_detail where b.....) as act_data from tb_primary where b...
) as b