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!

need query to get the data rows which are not in sequence.

user10991018Dec 11 2020

Hi ,

can you please tell me how can I get the data rows which are not in sequence.
for eg.
CREATE TABLE "DSGCIS"."TEST_SEQ"
( "SNO" VARCHAR2(20 BYTE),
"DESCRIPTION" VARCHAR2(20 BYTE)
)

SET DEFINE OFF;
Insert into TEST_SEQ (SNO,DESCRIPTION) values ('1','test1');
Insert into TEST_SEQ (SNO,DESCRIPTION) values ('2','test2');
Insert into TEST_SEQ (SNO,DESCRIPTION) values ('4','test4');
Insert into TEST_SEQ (SNO,DESCRIPTION) values ('5','test5');
Insert into tEST_SEQ (SNO,DESCRIPTION) values ('7','test7');

i want to get the top and bottom row of the sequence number missing
eg.
sno 3 and sno 6 are missing
so i want to get the data before and after 3
2 and 4th record
for 6th missing is 6 so 5th and 7 th record
thanks.

This post has been answered by Frank Kulash on Dec 11 2020
Jump to Answer
Comments
Post Details
Added on Dec 11 2020
14 comments
1,386 views