If I have data stored in a db like so.
fk start end
1 1000 1100
1 1030 1130
2 1000 1100
How can I write my query so I can get a result like:
fk timeslot occurences
1 1000 1
1 1030 2
1 1100 1
2 1000 1
2 1030 1
As you can tell I'm working in 30 min increments. I can achieve this server side but it requires me to either run a Query of Queries or hit the DB every time with counting the rows between the two times. If I can gather this info in 1 query my whole system will be so much faster.
FK is the id of my resource that is being reserved.
Basically I want to let the user know how many open spots are left based on the occurrences in the DB without hitting the DB multiple times if possible. Even QoQ hurts if I have to run one for each 30 min increment of the day.
You can also assume for fk 1 and 2 I have a known max starttime and max endtime if that matters.