Fixed bug in counting results from a join
Added base table to count query