Hi fellow stackers,
I have a question about how to “pivot/total” (for want of a better word) some data around in SQL server. The data is basically staff shifts and then hours lost from those shifts. So for example I have a record in one table
Staff_ID Shift_start Shift_end
37 09:00 17:30
And then we would give that person a lunch in another table
Staff_ID Start End
37 13:00 14:00
Of course we have more agents throughout the day and the scheme above is simplified but you get the idea. This is then transformed into the number of staff in 15 minutes
Interval Staff
09:00 5
09:15 7
09:30 6
And so on.
At the moment SQL server stores all of this but to “total” the agents up I have to bring things into Access and using arrays work out the number of staff in each 15 minute period and then save this data back to the database. It’s a quick process (<1500ms) but what I’m looking for is a way to do this in SQL server itself and not have to bring things to Access and write it back.
Am I barking up the wrong tree with this one?
EDIT:
I'm using SQL server 2008R2 Express