Hi Friends, I need the logic help, below is the table, below is input statement and data which is grouped by sno. input sno A B flag; cards; 1 0 1 . 1 1 1 1 1 10 2 10 1 1 1 1 1 10 2 10 2 0 1 . 2 10 1 10 2 1 1 1 2 10 1 10 2 1 1 1 3 10 1 10 3 99 1 . 3 1 1 1 3 10 2 10 4 1 1 1 4 0 1 . 4 10 2 10 ; The logic that has to be accomplished :, within each by group (grouped by sno), if the first record has flag=1 then it should be output and rest of the records within the group should be ignored. if the first record(grouped by sno) has flag=10, then it should proceed to the subsequent record and check for the flag till it finds either flag= 1 or 10 for first time with in the By group, if the found flag is 1 then rest of the records within the By group should be ignored, else if the found flag is 10 then all records including this record and rest of the records should be ignored with in the By group. if the first record(group by sno) has neither flag= 1 or 10 then, it should continue searching for either flag=1 or 10 for the first time within the By group, if the found flag is 1 then rest of the records within the By group should be ignored, else if the found flag is 10 then all records including this record and rest of the records should be ignored with in the By group The output for the above data should look like, sno A B flag 1 0 1 . 1 1 1 1 2 0 1 . 3 10 1 10 3 99 1 . 3 1 1 1 4 1 1 1 Your help is much appreciated. Thanks, Saravanan
... View more