andhracrazystar Posted June 22, 2018 Report Posted June 22, 2018 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? Quote
prabhu_pramod Posted June 23, 2018 Report Posted June 23, 2018 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 Quote
ImprovedLokesh Posted February 25, 2023 Report Posted February 25, 2023 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 ? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.