SELECT *,M.COUNTB / M.COUNTBFROM(SELECT A.ID,A.NAME,A.COUNTA(SELECT COUNT(1) FROM TABLEB) AS COUNTBFROM TABLEA A) M