I have a table with ranges of weeks (week number, start date, end date) and a table with training dates (for writing tutors (tutor ID, tutorial_date, type of tutorial (A or B).
I want to create two queries that show the week ranges (week 1, week 2) above, with the names of teachers on the side with textbook counters (type “A”) in this range of week dates in each block this week.
The result should look like this:
Counting Type A Training Aids
Tutor|Week One|Week Two|Week Three|Week Four|Total
Joe | 3 | 5 | 7 | 8 | 23
Sam | 2 | 4 | 3 | 8 | 17
Having said that, Joe completed 3 textbooks in the first week, five in two weeks, 7 in the third week and 8 in week 4.
The second query should display the totals for the textbook type "A" and type "B"
Tutor|Week One|Week Two|Week Three|Week Four|Total |
Joe | 3/1 | 5/3 | 7/2 | 8/2 | 23/8 |
Sam | 2/3 | 4/4 | 3/2 | 8/3 | 17/12 |
, , 3 A 1 B.
( )
Tutor | Tutorial_ID | Tutorial Date |Type|
------------------------------------------
Joe | 1 | 2011-01-01 | A |
Joe | 2 | 2011-01-02 | A |
Joe | 3 | 2011-01-03 | A |
Joe | 4 | 2011-01-03 | B |
Sam | 5 | 2011-01-01 | A |
Sam | 6 | 2011-01-02 | A |
Sam | 7 | 2011-01-03 | B |
:
weekNumber |startDate |endDate
1 |2011-01-01|2011-01-15
SQL Server 2005