Hello,

I would like to merge events if they have EXACTLY the same teachers and groups and the enddate of the first is the same as the startdate of the next.
The results should then be one event with its own startdate and with the enddate of the next(see example).
Tables :
Events( Id, StartDate, EndDate)
TeachersPerEvent( TeacherId, EventId )
GroupsPerEvent( GroupId, EventId )

Lets say I have the following data :
Events( 1, '2013-06-12 08:30', '2013-06-12 09:30')
Events( 2, '2013-06-12 09:30', '2013-06-12 10:30')
TeachersPerEvent( 1, 1 )
TeachersPerEvent( 2, 1 )
TeachersPerEvent( 1, 2 )
TeachersPerEvent( 2, 2 )
GroupsPerEvent( 1, 1 )
GroupsPerEvent( 2, 1 )
GroupsPerEvent( 1, 2 )
GroupsPerEvent( 2, 2 )

Because Event 1 has the same enddate as the startdate of event 2 and both events have EXACTLY the same teachers and groups I want to have 1 result and this is something like : EventId : 1, StartDateTime : '2013-06-12 08:30', EndDateTime : '2013-06-12 10:30'

I already made some joins, now I need to find a way to put in the equation to merge the event-records.

Can anyone help with this?

gr Coen Dunnink
The Netherlands