Ver Mensaje Individual
  #6 (permalink)  
Antiguo 29/05/2012, 14:37
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: Vistas de los meses del año.

Código SQL:
Ver original
  1. SELECT datepart(YEAR, Fecha), SUM(MontoAcumulado), Empleado
  2. FROM Empleados
  3. WHERE datediff(YEAR, Fecha, getdate()) <= 7
  4. GROUP BY Empleado, datepart(YEAR, Fecha)
  5. ORDER BY Empleado, datepart(YEAR, Fecha)
  6.  
  7. UNION
  8.  
  9. SELECT 2013,0,0,0,0,0,0,0,0...0
  10. UNION
  11. SELECT 2014,0,0,0,0,0,0,0,0...0
  12. UNION
  13. SELECT 2015,0,0,0,0,0,0,0,0...0
  14. .
  15. .
  16. .
  17. SELECT 20N,0,0,0,0,0,0,0,0...0

Saludos!
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me