Ver Mensaje Individual
  #12 (permalink)  
Antiguo 09/09/2009, 14:27
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

así


Código sql:
Ver original
  1. mysql> 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;
  2. +---------------------+------------+------------------+------------------+
  3. | id_categoria_gastos | fecha      | categoria_gastos | SUM(e.gastos)    |
  4. +---------------------+------------+------------------+------------------+
  5. |                 167 | 2009-06-01 | Esponsor         |              410 |
  6. |                 170 | 2009-06-01 | Gastos bancarios | 1.19000005722046 |
  7. |                 192 | 2009-06-01 | Moviles          | 220.589996337891 |
  8. |                 217 | 2009-07-02 | Transferencia    |             2999 |
  9. +---------------------+------------+------------------+------------------+
  10. 4 ROWS IN SET (0.00 sec)
  11.  
  12. mysql>
__________________
Without data, You are another person with an opinion.
W. Edwads Deming