Ver Mensaje Individual
  #2 (permalink)  
Antiguo 14/08/2013, 09:18
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 8 meses
Puntos: 774
Respuesta: balance por año en SQL 2008

si todo es sobre la misma tabla, en lugar de hacer subquerys puedes hacer algo asi

Código SQL:
Ver original
  1. SELECT
  2. CASE WHEN MONTH(ene) ant tipomov='E' THEN SUM(1) END AS enero,
  3. CASE WHEN MONTH(feb) ant tipomov='E' THEN SUM(1) END AS feb
  4. FROM tabla
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me