Ver Mensaje Individual
  #15 (permalink)  
Antiguo 10/09/2009, 09:46
manupalaya
 
Fecha de Ingreso: enero-2007
Mensajes: 156
Antigüedad: 17 años, 3 meses
Puntos: 3
Respuesta: Consulta Mysql - Solo suma una fila

Hola de nuevo,

he probado con el where esto:

Código PHP:
SELECT e.id_categoria_gastos,e.fecha,cg.categoria_gastos,sum(e.gastosFROM employee e INNER JOIN categoria_gastos cg USING(id_categoria_gastosGROUP BY e.id_categoria_gastos WHERE Fecha BETWEEN '2009-06-01' AND '2009-06-31' 
Y me sale este error:
Código:
 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 'WHERE Fecha BETWEEN '2009-06-01' AND '2009-06-31'
LIMIT 0, 30' at line 1

Y con la query de date esto:

Código PHP:
SELECT e.id_categoria_gastos,e.fecha,cg.categoria_gastos,sum(e.gastosFROM employee e INNER JOIN categoria_gastos cg USING(id_categoria_gastosGROUP BY e.id_categoria_gastos where date_format(fecha,'%Y-%m') = '2009-06' 
Y con esta me sale este error:

Código:
SELECT e.id_categoria_gastos,e.fecha,cg.categoria_gastos,sum(e.gastos) FROM employee e INNER JOIN categoria_gastos cg USING(id_categoria_gastos) GROUP BY e.id_categoria_gastos where date_format(fecha,'%Y-%m') = '2009-06'

Bueno gracias por tu apoyo, de nuevo :)