更新时间:2023-01-28 17:16:52
使用PIVOT
试试自己
http://blog.sqlauthority.com/20 08/06/07 / sql-server-pivot-and-unpivot-table-examples / [ ^ ]
Use PIVOT
Try yourself
http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/[^]
你可以在sql中进行旋转..
点击以下链接获取更多信息。
在SQL查询中使用数据透视的简单方法 [ ^ ]
看起来和你的要求一样。
You can do pivoting in sql..
follow the link below for more info.
Simple Way To Use Pivot In SQL Query[^]
It seems like same as your requirement.
试试这个:
Try this:
SELECT EmployeeDetailID, name, [May-13],[Jun-13],[Jul-13]
FROM
(SELECT EmployeeDetailID, name, AbsentDays, month FROM table1) AS src
PIVOT
(
sum(AbsentDays) FOR month IN ([May-13],[Jun-13],[Jul-13])
)AS pvt