如何模仿日历表
d y m weeknr weekday
2007-1-1 2007 1 1 2
2007-1-2 2007 1 1 3
2007-1-3 2007 1 1 4
2007-1-4 2007 1 1 5
2007-1-5 2007 1 1 6
2007-1-6 2007 1 1 7
2007-1-7 2007 1 2 1
2007-1-8 2007 1 2 2
2007-1-9 2007 1 2 3
2007-1-10 2007 1 2 4
2007-1-11 2007 1 2 5
2007-1-12 2007 1 2 6
2007-1-13 2007 1 2 7
2007-1-14 2007 1 3 1
2007-1-15 2007 1 3 2
2007-1-16 2007 1 3 3
2007-1-17 2007 1 3 4
2007-1-18 2007 1 3 5
2007-1-19 2007 1 3 6
2007-1-20 2007 1 3 7
2007-1-21 2007 1 4 1
2007-1-22 2007 1 4 2
2007-1-23 2007 1 4 3
2007-1-24 2007 1 4 4
2007-1-25 2007 1 4 5
2007-1-26 2007 1 4 6
2007-1-27 2007 1 4 7
2007-1-28 2007 1 5 1
2007-1-29 2007 1 5 2
2007-1-30 2007 1 5 3
2007-1-31 2007 1 5 4
2007-2-1 2007 2 5 5
2007-2-2 2007 2 5 6
2007-2-3 2007 2 5 7
2007-2-4 2007 2 6 1
2007-2-5 2007 2 6 2
2007-2-6 2007 2 6 3
2007-2-7 2007 2 6 4
2007-2-8 2007 2 6 5
2007-2-9 2007 2 6 6
2007-2-10 2007 2 6 7
2007-2-11 2007 2 7 1
2007-2-12 2007 2 7 2
2007-2-13 2007 2 7 3
2007-2-14 2007 2 7 4
2007-2-15 2007 2 7 5
2007-2-16 2007 2 7 6
2007-2-17 2007 2 7 7
2007-2-18 2007 2 8 1
2007-2-19 2007 2 8 2
2007-2-20 2007 2 8 3
2007-2-21 2007 2 8 4
2007-2-22 2007 2 8 5
2007-2-23 2007 2 8 6
2007-2-24 2007 2 8 7
2007-2-25 2007 2 9 1
2007-2-26 2007 2 9 2
2007-2-27 2007 2 9 3
2007-2-28 2007 2 9 4
2007-3-1 2007 3 9 5
2007-3-2 2007 3 9 6
2007-3-3 2007 3 9 7
2007-3-4 2007 3 10 1
2007-3-5 2007 3 10 2
2007-3-6 2007 3 10 3
2007-3-7 2007 3 10 4
2007-3-8 2007 3 10 5
这样的表如何模仿成逆规范化的日历表
year weekNr MothNr dateMonday dateTu dateW dateTh dateF dateS dateSun
2007 1 1 Null 1 2 3 4 5 6
2007 2 1 7 8 9 10 11 12 13
------解决方案--------------------select y as [year],weeknr,m as [month],
dateMonday =max(case when weekday=1 then day(d) end),
dateTu=max(case when weekday=2 then day(d) end),
dateW=max(case when weekday=3 then day(d) end),
dateTh=max(case when weekday=4 then day(d) end),
dateF=max(case when weekday=5 then day(d) end),
dateS=max(case when weekday=6 then day(d) end),
dateSun=max(case when weekday=7 then day(d) end)
from T
group by y,weeknr,m