select t1.id_q ,t1.pt ,t2.pt
from (select count(id_q) as pt ,id_q where table1 group by id_q) as t1
left join (select count(id_q) as pt ,id_q where table2 goupt by id_q) as t2
on t1.id_q=t2.id_q
order by t1.id_q
select t1.id_q ,t1.pt+t2.pt
from (select count(id_q) as pt ,id_q where table1 group by id_q) as t1
left join (select count(id_q) as pt ,id_q where table2 goupt by id_q) as t2
on t1.id_q=t2.id_q
order by t1.id_q
กรณีใช้ sum ก็แทนที่ count ไปใช้ได้เหมือนกันครับ Code
select t1.id_q ,t1.pt+t2.pt
from (select sum(id_q) as pt ,id_q where table1 group by id_q) as t1
left join (select sum(id_q) as pt ,id_q where table2 goupt by id_q) as t2
on t1.id_q=t2.id_q
order by t1.id_q
select t1.id_q ,t1.pt,t2.pt
from (select count(id_q) as pt ,id_q from table1 group by id_q) as t1
left join (select count(id_q) as pt ,id_q from table2 group by id_q) as t2
on t1.id_q=t2.id_q
order by t1.id_q