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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to join and get desired rows from same table

as maSep 24 2024

Hi All,

I have data shown as below and my requirement is to get 1st row and last row from the data set because 1st rows has c4 flag as Y and last row shows 1 as reference to 1st row column c1.

 select 1 c1, 1 c2, 1 c3, ‘Y’ c4 from dual union all  
 select 1 c1, 2 c2, 2 c3, ‘N’ c4 from dual union all  
 select 1 c1, 3 c2, 3 c3, ‘N’ c4 from dual union all  
 select 1 c1, 4 c2, 1 c3, ‘N’  c4 from dual;

Thank you in advance for you feedback and please let me know if you have any questions related t the requirement.

Comments
Post Details
Added on Sep 24 2024
6 comments
106 views