I have the following problem:
I have table:
TEST_TABLE
x_Id|y_Id
---------
2| 7
2| 8
3| 7
4| 7
5| 8
I want remove record if x_Id has y_Id(7) and y_Id(8). And update y_Id to 7 if y_Id = 8 and y_Id(7) is not exist in the unique x_Id.
x_Id and y_Id is composite key.
Example of result:
TEST_TABLE
x_Id|y_Id
---------
2| 7
3| 7
4| 7
5| 7
These queries do not use corelated subqueries (ones where they must be executed for every row of the outer query), so they should be quite efficient.