fix error in subject count queries - eliminate double joins