I have a query which is pretty simple in that it just gets records from a table, the output is like this:
ID group StatusType Task DateAdministered ScoreA ScoreB
5199 MSP Completed Follow Up Contact 2011-04-01 00:00:00.000 2 5
5199 MSP Completed Follow Up Contact 2011-06-02 00:00:00.000 2 7
5199 MSP Completed Follow Up Contact 2011-06-02 00:00:00.000 2 8
5199 MSP Completed Follow Up Contact 2011-06-02 00:00:00.000 2 7
5199 MSP Completed Follow Up Contact 2011-04-28 00:00:00.000 4 8
5199 MSP Completed Follow Up Contact 2011-06-02 00:00:00.000 2 7
5199 MSP Completed Follow Up Contact 2011-05-19 00:00:00.000 2 7
5199 MSP Completed Follow Up Contact 2011-05-26 00:00:00.000 3 7
5199 MSP Completed Follow Up Contact 2011-06-02 00:00:00.000 3 7
5199 MSP Completed Follow Up Contact 2011-06-09 00:00:00.000 1 6
5199 MSP Completed Follow Up Contact 2011-06-15 00:00:00.000 3 5
5199 MSP Completed Follow Up Contact 2011-06-23 00:00:00.000 2 6
5199 MSP Completed Follow Up Contact 2011-06-30 00:00:00.000 1 6
5199 MSP Completed Follow Up Contact 2011-07-07 00:00:00.000 4 6
5199 MSP Completed Follow Up Contact 2011-07-14 00:00:00.000 3 6
5199 MSP Completed Follow Up Contact 2011-07-21 00:00:00.000 2 7
What I need to do is re-organize the data into columns and not rows based on the date closest to the end of the month for a particular year of the DateAdministered for each ID, group, StatusType, and Task. In other words, if there are two rows for a task in April, I will need the max date of those two and the report on ScoreA and ScoreB. The do the same for May, June, etc...
The end result should look like this:
ID group StatusType Task April Assessment ScoreA ScoreB May Assessment ScoreA ScoreB June Assessment ScoreA ScoreB July Assessment ScoreA ScoreB
5199 MSP Completed Follow Up Contact 4/1/2011 2 5 5/26/2011 3 7 6/30/2011 1 6 7/21/2011 2 7
I have tried several things and I just am not sure of the best way to do this. This almost seems like something for a pivot but don't need to SUM or ADD any columns, so I am not sure how that would work if I need a pivot.