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.
:RUN_TYPE1SWITCH_TYPE1IDRUN_DATE
SQL:SELECT * FROM T_DATA a WHERE a.SWITCH_TYPE
IN("1") AND (a.RUN_TYPE
) IN
("1") ORDER BY ID , RUN_DATE
:
:
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?