I'm a bit lost with all of this but this will fix your count problem
SELECT FIELD, field2, COUNT (*) AS FIELD3
FROM tables
WHERE conditions
GROUP BY FIELD, field2
this way if you have the following data
smith, jones
smith, peters
brown, jones
brown, peters
brown, williams
brown, williams
smith, jones
you will get back
===========
smith, jones, 2
smith, peters, 1
brown, jones, 1
brown, peters, 1
brown, williams, 2
You will get unusual results when you try to use a distinct and a group by in the same query.