Hi @Garcia, Luis (NonEmp)
There are different ways that can be used to retrieve such data: NOT IN, NOT EXISTS and LEFT JOIN.
For me, I prefer NOT EXISTS. Unlike 'EXISTS and IN', 'NOT EXISTS and NOT IN' are not equivalent in all cases. Specifically, when NULLs are involved, they will return different results. To be totally specific, when the subquery returns even one null, NOT IN will not match any rows.
Please refer to this similar thread: NOT IN vs NOT EXISTS
Regarding performance, you could refer to this article for more details: T-SQL commands performance comparison – NOT IN vs SQL NOT EXISTS vs SQL LEFT JOIN vs SQL EXCEPT
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.