Jump to content

Oracle /DBA Experts .. Urgent Help Needed


Recommended Posts

Posted

I have a table's  (SO and SO LINE) structure like this below.

SO# 1234
 SO Line# 1
   SO Del Line# 1
 SO Line# 2
   SO Del Line# 1
   SO Del Line# 2

I'm joining both to produce below results.

SO 12345, LINE1, DEL 1
SO 12345, LINE2, DEL 1
SO 12345, LINE2, DEL 2

Now I want to pick only ROW1 from the DEL Line like below

SO 12345, LINE1, DEL 1
SO 12345, LINE2, DEL 1
 

How can I do that in Oracle SQL?

 

Posted

select * from SO a, SOLINE b
where
a.id = b.id
and b.delid= (select min(b1.delid) from SOLINE b1
where b.id = b1.id
and b.delid = b1.delid);

ID is the PK-FK column between SO & SOLINE
DELID is the column  unique in SOLINE for PK-FK from above
Change the MIN to MAX if you want DEL2 instead of DEL1

  • 4 years later...
Posted
On 6/22/2018 at 2:03 PM, andhracrazystar said:

I have a table's  (SO and SO LINE) structure like this below.

SO# 1234
 SO Line# 1
   SO Del Line# 1
 SO Line# 2
   SO Del Line# 1
   SO Del Line# 2

I'm joining both to produce below results.

SO 12345, LINE1, DEL 1
SO 12345, LINE2, DEL 1
SO 12345, LINE2, DEL 2

Now I want to pick only ROW1 from the DEL Line like below

SO 12345, LINE1, DEL 1
SO 12345, LINE2, DEL 1
 

How can I do that in Oracle SQL?

 

40+ uncle still DBA work ?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...