Calling SQL Server query masters! I need help with a query i am trying to accomplish. I need to build an output that counts records by dynamic columns based upon a date field in the record. The data looks like this:
classId | Source | Appt_Date |
1 | East | 2/1/2019 |
2 | West | 2/14/2019 |
3 | North | 2/22/2019 |
4 | East | 2/23/2019 |
5 | South | 3/1/2019 |
6 | East | 3/2/2019 |
7 | West | 3/2/2019 |
8 | North | 3/7/2019 |
9 | North | 3/11/2019 |
10 | South | 3/22/2019 |
My desired output would be something like this:
2/2/2019 | 2/9/2019 | 2/16/2019 | 2/23/2019 | 3/2/2019 | 3/9/2019 | 3/16/2019 | 3/23/2019 | Total | |
East | 1 | 1 | 1 | 3 | |||||
North | 1 | 1 | 1 | 3 | |||||
South | 1 | 1 | 2 | ||||||
West | 1 | 1 | 2 | ||||||
Total | 1 | 0 | 1 | 2 | 3 | 1 | 1 | 1 | 10 |
Grateful to any one who can help out with this one.