• 如何履行专用职能
i 有一个数据表
Day Period subject fromtime totime
----------------------------------------------
Monday 1st English 9:30 10:15
Monday 1st English 9:30 10:15
Monday 5th English 1:30 2:20
Monday 8th English 3:40 4:30
但需要格式
day period(1st) 2nd 3rd...... 5th... 8th
--------------------------------------------------------------------------
Monday 1st nill nill 5th 8th
english english english
Tuesday .......
这样做。
• 如何以这种形式履行专用职能。
请帮助我。
i) 使用我的询问
SELECT DAY, [1st],[2nd],[3rd],[4th], [5th],[6th],[7th], [8th]
FROM
(
SELECT Day, Period, Subject,FromTime,ToTime
FROM StaffTimeTableEntry
) up
PIVOT (Min(Subject) FOR Period IN ([1st],[2nd],[3rd],[4th], [5th],[6th],[7th], [8th])) AS pvt
order by Day
结果
day 1st 2nd 3rd 4th 5th 6th 7th 8th
----------------------------------------------------------------------------------
Friday NULL NULL NULL NULL NULL NULL English NULL
Monday NULL NULL NULL NULL English NULL NULL NULL
Monday NULL NULL NULL NULL NULL NULL NULL English
Monday English NULL NULL NULL NULL NULL NULL NULL
Saturday NULL NULL NULL NULL NULL English NULL
Thursday NULL NULL NULL English NULL NULL NULL
Tuesday NULL English NULL NULL NULL NULL NULL NULL
Tuesday NULL NULL NULL NULL NULL English NULL NULL
Wednesday NULL NULL NULL NULL NULL English NULL
但这里也有3个单天记录,而不是一个单天记录。
如何每1天获得一次记录?