我有一个非常复杂的情况,我需要在垂直表上使用PIVOT语句,我想请求帮助以实现我的目标。
我的目标是使用带有2个参数的SQL Server 2008创建存储过程过程:Year&由用户定义的月份。
然后,我需要我的SQL语句将垂直数据返回到格式良好的结果:
Information Transaction_Date
--------------- ----------------
Information # 1 2014-04-28
Information # 2 2014-04-28
Information # 3 2014-04-28
Information # 4 2014-04-28
Information # 5 2014-04-29
Information # 6 2014-04-29
Information # 7 2014-04-29
Information # 8 2014-04-30
Information # 9 2014-04-30
Information # 10 2014-05-01
Information # 11 2014-05-01
Information # 12 2014-05-05
Information # 13 2014-05-05
Information # 14 2014-05-06
Information # 15 2014-05-06
Information # 16 2014-05-07
Information # 17 2014-05-07
Information # 18 2014-05-07
Information # 19 2014-05-08
Information # 20 2014-05-12
Information # 21 2014-05-12
Information # 22 2014-05-14
Information # 23 2014-05-14
Information # 24 2014-05-14
Information # 25 2014-05-14
Information # 26 2014-05-14
Information # 27 2014-05-16
Information # 28 2014-05-16
Information # 29 2014-05-16
Information # 30 2014-05-19
Information # 31 2014-05-19
Information # 32 2014-05-22
Information # 33 2014-05-22
Information # 34 2014-05-23
Information # 35 2014-05-24
Information # 36 2014-05-24
Information # 37 2014-05-26
Information # 38 2014-05-26
Information # 39 2014-05-26
Information # 40 2014-05-26
Information # 41 2014-05-26
Information # 42 2014-05-28
Information # 43 2014-05-28
Information # 44 2014-05-28
Information # 45 2014-05-29
Information # 46 2014-05-29
Information # 47 2014-05-29
Information # 48 2014-05-30
Information # 49 2014-05-31
Apr 28 - May 04 (11) May 05 - May 11 (8) May 12 - May 18 (10) May 19 - May 25 (7) May 26 - June 01 (13)
-------------------- ------------------- -------------------- -------------------- --------------------
Information # 1 Information # 12 Information # 20 Information # 30 Information # 37
Information # 2 Information # 13 Information # 21 Information # 31 Information # 38
Information # 3 Information # 14 Information # 22 Information # 32 Information # 39
Information # 4 Information # 15 Information # 23 Information # 33 Information # 40
Information # 5 Information # 16 Information # 24 Information # 34 Information # 41
Information # 6 Information # 17 Information # 25 Information # 35 Information # 42
Information # 7 Information # 18 Information # 26 Information # 36 Information # 43
Information # 8 Information # 19 Information # 27 Information # 44
Information # 9 Information # 28 Information # 45
Information # 10 Information # 29 Information # 46
Information # 11 Information # 47
Information # 48
Information # 49