DB2 database queries qualified data in adjacent data (time adjacent)

question: query all data whose RUN_TYPE is 1 and SWITCH_TYPE is 1 in adjacent time (RUN_DATE) of ID.

data sheet: Tunable data, as shown in the figure.

clipboard.png

:RUN_TYPE1SWITCH_TYPE1IDRUN_DATE

SQL:SELECT * FROM T_DATA a WHERE a.SWITCH_TYPEIN("1") AND (a.RUN_TYPE) IN
("1") ORDER BY ID , RUN_DATE
:

:
clipboard.png

unresolved: the query result with an ID of 4 does not meet the requirements, and the two pieces of data do not meet the conditions of contiguous RUN_DATE (there is a RUN_TYPE of 0 in the middle).

question: how to compare adjacency (adjacent time) in SQL?

Nov.22,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c1fe8d-3349f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c1fe8d-3349f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?