Display both null and not null under same id but not both null or not null like XOR logic Consider the following Employee table:


  


In this table I need to select only the ids which have both null and not null marks, and it should not be both not null or both are null in col1.
Select NullTest.ID, NullTest.Col1
    From NullTest 
    Join (Select ID From NullTest Where Col1 Is Not Null Group By ID) 
         NotNulls 
         On NotNulls.ID = NullTest.ID
    Join (Select ID From NullTest Where Col1 Is Null Group By ID) 
         Nulls 
         On Nulls.ID = NullTest.ID ;