sql server - SSRS report showing number of appointments per customer per week (layout) -
I would like to create a report that shows the number of meetings per customer per week in a calendar type layout. I am using SQL Server Reporting Services 2005. To say for simplicity means we have only these two tables:
Customers
- ID
- Name
What is the most effective way to prepare a report with this layout?
| Week # Customer | 1 | 2 | 3 | 4 | 5 | 6 | ... | 52 | Total --------- + - + - + + + + + + + + + + + + + + + - + Result one | 0 | 2 | 0 | 1 | 0 | 0 | ... | 1 | 4th b. 0 | 1 | 0 | 1 | 1 | 0 | ... | 0 | 3 casts | 0 | 0 | 0 | 1 | 0 | 0 | ... | 0 | 1st Caste | 1 | 0 | 0 | 0 | 1 | 0 | ... | 0 | 2
Edit: Remember that some years may start from week # 53.
I misled all 52 (53) weeks, and counted only those people Where I put the test data. Hope you get this idea.
Announcement @ Customer Table ([ID] Zero primary primary key, [name] nerve (50) is not blank); DECLARE @Appointment TABLE ([ID] Zero primary primary key, [customer ID] int null, [anytime] datetime tap default meet (), [theme] nerve (50) not faucet; # Include in customer selection 1, Select 'Aaron Bor' Union 2, 'John Adams' Union All Select 3, 'George Washington'; Appointment 1, 1, '2009-01-04', 'Ants in Pants' 2, 1, '2009-02-04', Select 'Follow Up' Union 3, 1, '' 2009-07-20 ',' Check-Up 'Union All Substitute 4, 2,' 2009-02-05 ',' Wellness Check 'union all s Select 5, 2, '2009-11-26', 'Private' Union Select All 6, 2, '2009-06-03', 'Stubbed Toe' Union Select All 7, 3, '2009- 11-27 ',' Dantashah Union All Select 8, 3, '2009-11-28', 'Crown', as well as together with Appointments (SELECT c.Id, c.Name, DATEPART (wk, a. OkurredOn) [Week], from @ COUNT (c.Id) [count] @ AppointmentA visit@CustomerId = c.Id group at CIID, C. Name, DATEPART (wk, a.OccurredOn), Pivot As Appointments (SELECT [Id], [Name], ISNULL ([53], 0) [53], ISNULL ([2] 0, [0] [2], ISUNLL ([30], 0) [30 ], As in ISNUL ([48], 0) [2], ISUnLL ([6], 0) [6], ISUnLL ([23], 0) [23] [48] [PivotAppointments] [PivotApps] *, [53] + [2] + [6] + [23] for the week ([2], [6], [23], [30], [48], [53]) ] Results in Pivot Appointments
+ [30] + [48] [total]:
[ID] [name] [53] [2] ] [6] [23] [30] [48] [Total] ------------------------------ ------- -------------------------------- 1 Aaron Bor 0 1 1 0 1 0 2 2 George Washington 0 0 0 0 2 2 3 John Adams 0 1 1 0 1 3
Comments
Post a Comment