Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/10/2008, 13:43
bellleti
 
Fecha de Ingreso: abril-2008
Mensajes: 144
Antigüedad: 18 años, 6 meses
Puntos: 1
Pregunta problem con max , group by

tengo esa consulta que me funciona bien, pero cuando le pongo el max i el group by me dice que no le gusta :(

Código PHP:

SELECT h
.codi,h.herd_id,p.testdim,p.testdate, p.milk, p.fat,p.scc,p.prot,p.herd_id, a.herd_id,max(a.parity),a.endparitydate
                   FROM production p 
, herd h, ag_parity a
                  WHERE p
.TESTDATE  = '2008-05-07'
                 
and p.herd_id= a.herd_id 
                 
and a.herd_id= h.herd_id
                 
and p.herd_id= h.herd_id
                 order by h
.codi
group by a
.herd_id; 
mensaje error:

Código PHP:
Error

consulta SQL
: Documentación

SELECT h.codi, h.herd_id, p.testdim, p.testdate, p.milk, p.fat, p.scc, p.prot, p.herd_id, a.herd_id, max( a.parity ) , a.endparitydate
FROM production p
, herd h, ag_parity a
WHERE p
.TESTDATE = '2008-05-07'
AND p.herd_id = a.herd_id
AND a.herd_id = h.herd_id
AND p.herd_id = h.herd_id
ORDER BY h
.codi
GROUP BY a
.herd_id
LIMIT 0 
, 30

MySQL ha dicho
: Documentación
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group by a.herd_id
LIMIT 0, 30 at line 1 
me pueden ayudar pk me pasa esto?

Última edición por bellleti; 28/10/2008 a las 13:43 Razón: cositas