SQL - How to use PIVOT -


I have a very complex situation where I need to use a PIVOT statement in the vertical table and I will help you I want to ask for my purpose.

My objective is to create a stored procedure process with 2 parameters with SQL Server 2008: Year & amp;

  • Based on the following example, this statement 5 will be defined for various work weeks for the year and week;
  • For every week, this statement should be returned to the list of information attached to it
  • The headline of each week should be displayed as following: April 28 - May 04 May 05 - May 11 May 12 May 18 May 19 May 25 May 26 - June 01
  • The header should contain the number of records / information per week. Value is presented inside "()"

  notification Transaction_Date --------------- ------- --- ------ Notification # 1 2014-04-28 Notice # 2 2014-04-28 Notice # 3 2014-04-28 Notice # 4 2014-04-28 Notice # 5 2014-04-29 Notice # 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 Suggested Ation # 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 Notice # 42 2014-05-28 Information # 43 2014-05 - 28 Information # 44 2014-05-28 Information # 45 2014-05-29 Notice # 46 2014-05-29 Notice # 47 201 4-05-29 Information # 48 2014-05-30 Information # 49 2014-05-31 April 28 - May 04 (11) May 05 - May 11 (8) May 12 - May 18 (10) May 19-May 25 (7) May 26 - June 01 (13) ---------- ---------- ------------------ - -------------------- ------------------- --------- ----------- Notice # 1 Notice # 12 Notice # 20 Notice # 30 Notice # 21 Notice # 31 Notice # 38 Notice # 3 Notice # 14 Notice # 22 Notice # 32 Notice # 39 Notice # 4 Notification # 15 Information # 23 Notice # 33 Notice # 40 Notice # 34 Notice # 41 Notice # 6 Notice # 17 Notice # 25 Notice # 35 Notice # 42 Notice # 7 Notice # 18 Notice # 26 Notice # 36 Notice # 43 Notice # 8 Notifications # 19 Notice # 28s Contact # 45 Notification # 10 Notice # 29 Notice # 46 Notice # 11 Notice # 47 Notice # 48 Information # 49 >  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -