Durch Erweiterung der WHERE Bedingung habe ich es jetzt geschaft die richtige Ergebnismenge zu erhalten.
Code: Alles auswählen
select t1.nummer, pos.*
from tree as t1 join pos on t1.id = pos.ebindex
where t1.katid = 1119
and t1.ehoeher = (Select t2.ID from tree as t2 where t2.katid = 1119 and t2.ehoeher = '1' and t2.nummer = 1)
and t1.nummer >= 1
and t1.Nummer <= 2
or (t1.katid = 1119
and t1.ehoeher = (Select t3.ID from tree as t3 where t3.katid = 1119 and t3.ehoeher = '1' and t3.nummer = 1)
and (t1.nummer = 3 and cast(pos.X_aposnr as integer) <= 5))
order by 1, 8