PIVOT会将剩下的字段,做GROUP BY 的动作
如下示例
SELECT DATE, A.G, A.I, A.V, A.O, A.SC, A.LR, A.PR, A.HL FROM
(
select date,PNLID, judge FROM dbo.RCI_LOI2MOVEMENT
)B
PIVOT (COUNT(PNLID) FOR judge IN
(G, I, V, O, SC, LR, PR, HL )) A
WHERE DATE >= '2007-4-5' AND DATE <= '2007-4-11'
自动会以date作为GROUP BY 的栏位