Prueba esto:
Código sql:
Ver originalSELECT p.testdim, p.testdate, h.codi,hf.STATUS, h.date0,
datediff(now(), h.date0) AS diesinsemin, h.parts, h.curservices,
a.herd_id, MAX( a.parity ) , MAX( a.endparitydate )
FROM production p INNER JOIN herd h ON p.herd_id = h.herd_id INNER JOIN
ag_parity a ON a.herd_id = h.herd_id INNER JOIN herd_females hf ON p.herd_id = hf.herd_id
WHERE hf.STATUS <> 'n'
GROUP BY a.herd_id
No lo he probado.