troubleshooting Question

DB2: find value pairs

Avatar of Mi-Jack
Mi-Jack asked on
DB2SQL
6 Comments1 Solution535 ViewsLast Modified:
Hi all,

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.

Thank you,
Gene
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros