I am stumped how to approach this problem. Can anybody shed some light:
Given a table of the following structure (supplied by an automated data-logger)
ActivityCode
StartTime
EndTime
and the following simplified sample records
1 1:00 pm 2:00 pm
2 1:30 pm 2:30 pm
How would I construct a query or create a new table that shows the intersection of the two records i.e. calculate that activities 1 and 2 both occurred between 1:30 and 2:00 pm? Can it be done with SQL, or would a brute-force approach of walking thru all the records be required? The real dataset will contain thousands of records with many different activities. Once I get the solution for intersecting two activities, I would be interested in finding the intersection of three or more activies. Would probably also look for the intersection of one activity and NOT the other activity.
Not looking for the complete solution — just some guidance in the right direction, or if it’s even possible.
Thanks.