02/02/2012, 13:34
|
| | Fecha de Ingreso: agosto-2008
Mensajes: 142
Antigüedad: 16 años, 4 meses Puntos: 2 | |
Respuesta: Reportes de Ventas con PIVOT ando un poco perdido de hecho le meti el compute pero me manda las filas en blanco
te pongo mi codigo
SELECT DescVend, DescProd, DescCliente, [01] AS Ene, [02] AS Feb, [03] AS Mar, [04] AS Abr, [05] AS May, [06] AS Jun,
[07] AS Jul, [08] AS Ago, [09] AS Sept, [10] AS Oct, [11] AS Nov, [12] AS Dic
FROM
(
SELECT a.DescVend, b.DescProd, c.DescCliente, DATEPART(mm, Inv.Fecha) AS OrderMes, Inv.Monto
FROM Inversiones AS Inv
INNER JOIN TabVend AS a ON Inv.IdVEND=a.IdVend
INNER JOIN TabProd AS b ON Inv.IdProd=b.IdProd
INNER JOIN TabClientes AS c ON Inv.IdCliente=c.IdCliente
WHERE DATEPART(yy, Inv.Fecha)=2011
) piv
PIVOT
(
SUM (Monto)
FOR OrderMes IN
([01], [02], [03], [04], [05], [06], [07], [08], [09], [10], [11], [12])
) AS chld
ORDER BY DescCliente |