Im a bit stuck with the correct Database Operation…im feeling a bit stupid lol
Please check the basic example:

I want to Search for all Rows where the Connection Status is Empty
and when Name has any Duplicates that none of them should have the Value Connected.

Im not sure how i can do this operation with a huge List.

The Solution i came with is this one Below:
Screenshot 2567-07-12 at 15.19.46

But with a huge List of more than 1k Rows this Solution wouldnt be efficient…

Anyone here who can come with an more efficient solution? Id appreciate any help. Sitting for an hour and cant come up with a better solution