Sub Query problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My problem

2 tables:

PROBLEM
PROBLEM: PROBLEM_ID

example
PROBLEM_ID
22

HISTORY
HISTORY:HISTORY_ID
HISTORY:PROBLEM_ID
HISTORY:ACTIVITY (Options are 'BEGIN' or 'END')
HISTORY:NUMBER

example
HISTORY_ID PROBLEM_ID ACTIVITY NUMBER

1 22 BEGIN 2
2 22 END 2
3 22 BEGIN 1
4 22 END 6

For each PROBLEM:PROBLEM_ID there can be several HISTORY records, each BEGIN
has a corresponding END, I'm looking for a way to add the HISTORY:NUMBER for
the corresponding BEGIN / END?,

I can do a query which brings back both BEGIN & END but the next row brings
back the 1st BEGIN with the 2nd END
 
In your examples, you don't explain what 'number' is related to, is it an
activity number?
Also, you don't explain where this number comes from?
Before you can add something you need to know where it is coming from.
In your example there is no way to distinguish each begin and end other than
the sequence of history id.
You need to ask your question more clearly.

Dorian
 
Back
Top