Hi,
I could really use some help figuring out the following..
I have a table, lets call it Table (simplified, but this is what my question comes down to):
Header_ID | Line_ID
| Type_ID
|
---|
201 | 0 | 8000001 |
201 | 0 | 8000012 |
201 | 1 | 5 |
202 | 0 | 8000037 |
202 | 0 | 8000009 |
202 | 0 | 8000003 |
202 | 1 | 4 |
203 | 0 | 8000056 |
203 | 0 | 8000012 |
203 | 0 | 8000013 |
203 | 0 | 8000019 |
203 | 0 | 8000008 |
203 | 1 | 2 |
I need to write a 'select' query based on this table that generates the following:
Header_ID | Line_ID
| Type_ID
| Type2_ID
|
---|
201 | 0 | 8000001 | 5 |
201 | 0 | 8000012 | 5 |
202 | 0 | 8000037 | 4 |
202 | 0 | 8000009 | 4 |
202 | 0 | 8000003 | 4 |
203 | 0 | 8000056 | 2 |
203 | 0 | 8000012 | 2 |
203 | 0 | 8000013 | 2 |
203 | 0 | 8000019 | 2 |
203 | 0 | 8000008 | 2 |
Basically, for every unique Header_ID, I need to retrieve the Type_ID where Line_ID is 1 (Line_ID is always 0 or 1) and fill that in a new column Type2_ID, but without the lines where Line_ID is 1.
I'm quite lost at the moment and would appreciate some advice on this..