Tema: Consulta SQL
Ver Mensaje Individual
  #2 (permalink)  
Antiguo 08/04/2011, 02:48
quimfv
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 2 meses
Puntos: 574
Respuesta: Consulta SQL

Código MySQL:
Ver original
  1. SELECT Year(gasto.fingreso) as `anio`,
  2. Month(gasto.fingreso) as `Mes`,
  3. SUM(if(gasto.tipo='f' OR gasto.tipo='b',gasto.total,0)) as `Suma de f y b`,
  4. SUM(gasto.total) as `Suma de Totales`
  5. FROM gasto
  6. group by Year(gasto.fingreso), Month(gasto.fingreso)

Si?
__________________
Quim
--------------------------------------------------
Ayudar a ayudar es una buena práctica!!! Y da buenos resultados.