Dear All
I have a table in which each record has a start date and an end date. The following query appears successfully to count the number of occasions on which one record within the table overlaps with another:
SELECT Count(1)
FROM tblMain AS t1 INNER JOIN tblMain AS t2 ON [t1].[id] < [t2].[id]
WHERE NOT ([t1]![startdate] < [t2]![startdate] And [t1]![enddate] < [t2]![enddate] Or [t1]![startdate] > [t2]![startdate] And [t1]![enddate] > [t2]![enddate]);
What I am failing to discern is how to adapt this query to return the number of occasions on which one record in the table overlaps with TWO others.
Ideally what I'd like is a query in which column one returns the number of occasions two records overlap, column two returns the number of occasions on which three records overlap, column three returns the number of occasions on which four records overlap....and so on and so on.
It feels like it should be eminently possible but I have been comprehensively defeated and would be very grateful for some help!
I have a table in which each record has a start date and an end date. The following query appears successfully to count the number of occasions on which one record within the table overlaps with another:
SELECT Count(1)
FROM tblMain AS t1 INNER JOIN tblMain AS t2 ON [t1].[id] < [t2].[id]
WHERE NOT ([t1]![startdate] < [t2]![startdate] And [t1]![enddate] < [t2]![enddate] Or [t1]![startdate] > [t2]![startdate] And [t1]![enddate] > [t2]![enddate]);
What I am failing to discern is how to adapt this query to return the number of occasions on which one record in the table overlaps with TWO others.
Ideally what I'd like is a query in which column one returns the number of occasions two records overlap, column two returns the number of occasions on which three records overlap, column three returns the number of occasions on which four records overlap....and so on and so on.
It feels like it should be eminently possible but I have been comprehensively defeated and would be very grateful for some help!
Last edited: