I have a table with the following columns:
[i_year] [int] NOT NULL,
[i_month] [int] NOT NULL,
[i_day] [int] NOT NULL,
[i_hour] [int] NOT NULL,
[i_minute] [int] NOT NULL,
[i_second] [int] NOT NULL,
[i_state] [int] NOT NULL,
[i_id] [int] NOT NULL
i_state can only be 0 or 1
Every i_id starts with an i_state of 0, and then at some point the state changes to 1.
In some time, the state changes back to 0 - and so on.
How can I match i_state 0 to its corresponding i_state of 1 for a particular i_id?
I need to make sure that each i_state 0 has i_state 1, and that there are no
i_state 0 followed by i_state 0 - or i_state 1 followed by i_state 1. In other
words, that the sequence of events in time is always i_state 0 -> i_state 1.