如何模仿日历表
dymweeknrweekday
2007-1-12007112
2007-1-22007113
2007-1-32007114
2007-1-42007115
2007-1-52007116
2007-1-62007117
2007-1-72007121
2007-1-82007122
2007-1-92007123
2007-1-102007124
2007-1-112007125
2007-1-122007126
2007-1-132007127
2007-1-142007131
2007-1-152007132
2007-1-162007133
2007-1-172007134
2007-1-182007135
2007-1-192007136
2007-1-202007137
2007-1-212007141
2007-1-222007142
2007-1-232007143
2007-1-242007144
2007-1-252007145
2007-1-262007146
2007-1-272007147
2007-1-282007151
2007-1-292007152
2007-1-302007153
2007-1-312007154
2007-2-12007255
2007-2-22007256
2007-2-32007257
2007-2-42007261
2007-2-52007262
2007-2-62007263
2007-2-72007264
2007-2-82007265
2007-2-92007266
2007-2-102007267
2007-2-112007271
2007-2-122007272
2007-2-132007273
2007-2-142007274
2007-2-152007275
2007-2-162007276
2007-2-172007277
2007-2-182007281
2007-2-192007282
2007-2-202007283
2007-2-212007284
2007-2-222007285
2007-2-232007286
2007-2-242007287
2007-2-252007291
2007-2-262007292
2007-2-272007293
2007-2-282007294
2007-3-12007395
2007-3-22007396
2007-3-32007397
2007-3-420073101
2007-3-520073102
2007-3-620073103
2007-3-720073104
2007-3-820073105
这样的表如何模仿成逆规范化的日历表
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