Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Handling multiple conditions in single query

ZudarAug 31 2018 — edited Aug 31 2018

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_IDLine_ID
Type_ID
20108000001
20108000012
20115
20208000037
20208000009
20208000003
20214
20308000056
20308000012
20308000013
20308000019
20308000008
20312

I need to write a 'select' query based on this table that generates the following:

Header_IDLine_ID
Type_ID
Type2_ID
201080000015
201080000125
202080000374
202080000094
202080000034
203080000562
203080000122
203080000132
203080000192
203080000082

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..

This post has been answered by Hans Steijntjes on Aug 31 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 28 2018
Added on Aug 31 2018
8 comments
2,692 views