日期:2014-05-17 浏览次数:20562 次
SELECT
NAME
,MAX(CASE WHEN DATEPART(weekday,dt)=1 THEN f1 ELSE '' END) AS 周一f1
,MAX(CASE WHEN DATEPART(weekday,dt)=1 THEN f2 ELSE '' END) AS 周一f1
,MAX(CASE WHEN DATEPART(weekday,dt)=2 THEN f1 ELSE '' END) AS 周二f1
,MAX(CASE WHEN DATEPART(weekday,dt)=2 THEN f2 ELSE '' END) AS 周二f2
,MAX(CASE WHEN DATEPART(weekday,dt)=3 THEN f1 ELSE '' END) AS 周三f1
,MAX(CASE WHEN DATEPART(weekday,dt)=3 THEN f2 ELSE '' END) AS 周三f2
,MAX(CASE WHEN DATEPART(weekday,dt)=4 THEN f1 ELSE '' END) AS 周四f1
,MAX(CASE WHEN DATEPART(weekday,dt)=4 THEN f2 ELSE '' END) AS 周四f2
,MAX(CASE WHEN DATEPART(weekday,dt)=5 THEN f1 ELSE '' END) AS 周五f1
,MAX(CASE WHEN DATEPART(weekday,dt)=5 THEN f2 ELSE '' END) AS 周五f2
,MAX(CASE WHEN DATEPART(weekday,dt)=6 THEN f1 ELSE '' END) AS 周六f1
,MAX(CASE WHEN DATEPART(weekday,dt)=6 THEN f2 ELSE '' END) AS 周六f2
,MAX(CASE WHEN DATEPART(weekday,dt)=7 THEN f1 ELSE '' END) AS 周日f1
,MAX(CASE WHEN DATEPART(weekday,dt)=7 THEN f2 ELSE '' END) AS 周日f2
FROM test
GROUP BY NAME
ORDER BY MIN(id) ASC