I'm relatively new to SQL and am running into a lot of issues trying to figure this one out. I've tried using a LEFT JOIN, and dabbled in using functions to get this to work but to no avail.
For every UserID, if there is a NULL value, I need to remove all records of the Product ID for that UserID from my SELECT.
I am using SQL Server 2014.
Example Table
+--------------+-------------+---------------+ | UserID | ProductID | DateTermed | +--------------+-------------+---------------+ | 578 | 2 | 1/7/2017 | | 578 | 2 | 1/7/2017 | | 578 | 1 | 1/15/2017 | | 578 | 1 | NULL | | 649 | 1 | 1/9/2017 | | 649 | 2 | 1/11/2017 | +--------------+-------------+---------------+
Desired Output
+--------------+-------------+---------------+ | UserID | ProductID | DateTermed | +--------------+-------------+---------------+ | 578 | 2 | 1/7/2017 | | 578 | 2 | 1/7/2017 | | 649 | 1 | 1/9/2017 | | 649 | 2 | 1/11/2017 | +--------------+-------------+---------------+