D
DowningDevelopments
I have a table called students which shows information about students on a
database for a student housing company. I am trying to figure out which
students have been allocated to the same room at the same time.
Every student has a [students].[RoomRef] which says where they are staying
and ive done a find duplicates query of the RoomRef.
However this also shows previous tenants in the same room which is fine,
what im after is students who are in teh room at the same time
(misallocated). To do this i want to use the [students].[startDate] and
[students].[endDate] to compare if the end date of one student overlaps with
the startdate of the next, if there is then there has been a misallocation.
So far my duplicates query looks like this:
SELECT Students.RoomRefer, Students.StudentRef, Students.StartDate,
Students.EndDate
FROM Students
WHERE (((Students.RoomRefer) In (SELECT [RoomRefer] FROM [Students] As Tmp
GROUP BY [RoomRefer] HAVING Count(*)>1 )))
ORDER BY Students.RoomRefer;
How could i change this to show if there are overlaps for tenants of the
same room?
With much thanks for any help
Amit
database for a student housing company. I am trying to figure out which
students have been allocated to the same room at the same time.
Every student has a [students].[RoomRef] which says where they are staying
and ive done a find duplicates query of the RoomRef.
However this also shows previous tenants in the same room which is fine,
what im after is students who are in teh room at the same time
(misallocated). To do this i want to use the [students].[startDate] and
[students].[endDate] to compare if the end date of one student overlaps with
the startdate of the next, if there is then there has been a misallocation.
So far my duplicates query looks like this:
SELECT Students.RoomRefer, Students.StudentRef, Students.StartDate,
Students.EndDate
FROM Students
WHERE (((Students.RoomRefer) In (SELECT [RoomRefer] FROM [Students] As Tmp
GROUP BY [RoomRefer] HAVING Count(*)>1 )))
ORDER BY Students.RoomRefer;
How could i change this to show if there are overlaps for tenants of the
same room?
With much thanks for any help
Amit