select distinct a.obj_type as obj_type, b.obj_id as obj_id, a.date_value as anfangsdatum, b.date_value as enddatum from obj_date a, obj_date b join obj_int i on b.obj_id = i.obj_id where (a.field_id = 8 and b.field_id = 7 and a.obj_id = b.obj_id and a.obj_type=-17 and (a.date_value >= '04.10.2007' or b.date_value >= '04.10.2007') and ( (b.date_value >= '04.10.2007' and b.date_value <= DATEADD("d",4,'04.10.2007')) or (a.date_value >= '04.10.2007' and a.date_value <= DATEADD("d",4,'04.10.2007')) ) ) or (i.int_value = 1 and i.obj_type = -17 and i.version_id = 0 and i.field_id = 5)