Ver Mensaje Individual
  #6 (permalink)  
Antiguo 19/11/2013, 09:07
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: Consulta en northwind

bueno supongamos que la suma del año esta bien

Código SQL:
Ver original
  1. SELECT o.ShipCountry Pais,
  2. CASE WHEN datepart(yyyy,campo_fecha)=1996 THEN SUM(od.UnitPrice*od.Quantity) END AS [1996],
  3. CASE WHEN datepart(yyyy,campo_fecha)=1997 THEN SUM(od.UnitPrice*od.Quantity) END AS [1997],
  4. CASE WHEN datepart(yyyy,campo_fecha)=1998 THEN SUM(od.UnitPrice*od.Quantity) END AS [1998]
  5.  
  6.     FROM [ORDER Details] od
  7.     INNER JOIN Orders o ON o.OrderID=od.OrderID
  8.     GROUP BY o.ShipCountry
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me