Ver Mensaje Individual
  #2 (permalink)  
Antiguo 08/09/2009, 10:50
Avatar de huesos52
huesos52
Colaborador
 
Fecha de Ingreso: febrero-2009
Ubicación: Manizales - Colombia
Mensajes: 5.980
Antigüedad: 15 años, 2 meses
Puntos: 360
Respuesta: Consulta Mysql - Solo suma una fila

Código mysql:
Ver original
  1. SELECT categoria_gastos.categoria_gastos, t1.suma, Gastos FROM categoria_gastos INNER JOIN (select employee.id,SUM(employee.Gastos) from employee group by id)t1 on
  2. t1.idcategoria_gastos=categoria_gastos.idcategoria_gastos WHERE (YEAR(employee.Fecha) = 2009 AND MONTH(employee.Fecha) = 6) GROUP BY employee.id_categoria_gastos

es algo así.

En una subconsulta debes hacer primero la suma y después mostrarlña desde afuera.

saludos
__________________
Without data, You are another person with an opinion.
W. Edwads Deming