* Build and populate cursor for test: CREATE CURSOR PrevTest ; (iID I, ; dDate D) INSERT INTO PrevTest (iID, dDate) VALUES (1, {^2004-11-22}) INSERT INTO PrevTest (iID, dDate) VALUES (2, {^2004-11-23}) INSERT INTO PrevTest (iID, dDate) VALUES (3, {^2004-12-04}) INSERT INTO PrevTest (iID, dDate) VALUES (4, {^2004-12-06}) INSERT INTO PrevTest (iID, dDate) VALUES (5, {^2004-12-06}) INSERT INTO PrevTest (iID, dDate) VALUES (6, {^2004-12-18}) INSERT INTO PrevTest (iID, dDate) VALUES (7, {^2004-12-19}) INSERT INTO PrevTest (iID, dDate) VALUES (8, {^2004-12-31}) INSERT INTO PrevTest (iID, dDate) VALUES (9, {^2005-01-01}) INSERT INTO PrevTest (iID, dDate) VALUES (10, {^2005-01-21}) * Get 1st temporary cursor with "previous" row ID in each row: SELECT ; *, ; iID - 1 AS iPrevID ; FROM PrevTest ; INTO CURSOR Temp1 ; NOFILTER * Look up previous date for each row (if present), * if not present use NVL() and a dummy date far in the future * so the date difference will always be negative: SELECT ; A.*, ; NVL(B.dDate, {^2005-12-31}) AS dPrevDate ; FROM Temp1 A ; LEFT OUTER JOIN PrevTest B ; ON B.iID = A.iPrevID ; INTO CURSOR Temp2 ; NOFILTER * Now just get the rows that meet the date difference criterion: SELECT ; * ; FROM Temp2 ; WHERE dDate - dPrevDate >= 10 ; INTO CURSOR ResultIf you examine the cursors you'll see how it works.