You can combine both queries in one so called correlated query like this

"SELECT *, (SELECT COUNT(DISTINCT(id_registro)) as QTDE FROM table2 WHERE id_planoconta=table1.id) AS CountOfRegistro FROM table1 ORDER BY num ASC"

The green part is what used to be your first query, the red part is the correlated second query.

cheers,
</wqw>