Paste this into a new question or an answer at dba.stackexchange.com:
<!-- --> > CREATE TABLE table_name (Region, Location, Amount, "DATE", Name ) AS > SELECT 1, 'Location1', 500, DATE '2021-01-01', 'UserA' FROM DUAL UNION ALL > SELECT 1, 'Location1', -500, DATE '2021-01-02', 'UserA' FROM DUAL UNION ALL > SELECT 2, 'Location2', 700, DATE '2021-01-03', 'UserB' FROM DUAL > > <pre> 3 rows affected > </pre> <!-- --> > DELETE FROM table_name t > WHERE EXISTS ( > SELECT 1 > FROM table_name x > WHERE x.region = t.region > AND x.location = t.location > AND x.amount = -t.amount > AND x."DATE" IN (t."DATE" - 1, t."DATE" + 1) > AND x.name = t.name > ) > > <pre> 2 rows affected > </pre> <!-- --> > SELECT * FROM table_name; > > <pre> > REGION | LOCATION | AMOUNT | DATE | NAME > -----: | :-------- | -----: | :-------- | :---- > 2 | Location2 | 700 | 03-JAN-21 | UserB > </pre> *db<>fiddle [here](https://dbfiddle.uk/?rdbms=oracle_18&fiddle=963eab033d485705cfc32f86596f5ae4)*
back to fiddle