I get stuck with some SQL query which check if dateto from first row is not > than datefrom for second row within same ID.Maybe the easiest way is to present it on example:
ID DATEFROM DATETO PK
1234 20150512 20150518 1
1234 20150514 20150520 2
1234 20150519 null 3
2313 20150512 20150518 4
44341 20150512 null 5
Now, within id 1234 flow is:
1.2015-05-12 -> 2015-05-18
2.2015-05-13 -> 2015-05-20 WRONG
3.2015-05-19 -> null
In this example end date of first row is > than start date for second row. As output I would like to display PK id ( in this example:2).
Could anyone give me some hints how to approach this? I don't want SQL but just hints. Thanks in advance