Thanks a million everyone for everyone's response. Unfortunately, none of the solutions appear to be working on my end, and my guess is that the example I've provided is messed up.
So let me try again.
My table looks like this:
contract project activity
row1 1000 8000 10
row2 1000 8000 20
row3 1000 8001 10
row4 2000 9000 49
row5 2000 9001 49
row6 3000 9000 79
row7 3000 9000 78
Basically, the query I'm looking for would return "2000,49" for "contract, activity" because only contract #2000 has one, and ONLY one, unique activity value.
Again, thanks a million in advance,
boroatel
Best Answer
Updated to use your newly provided data:
The solutions using the original data may be found at the end of this answer.
Using your new data:
returns: 2000, 49
Solutions using original data
WARNING: The following solutions use the data previously given in the question and may not make sense for the current question. I have left them attached for completeness only.
This should get you a list of all the values in col1 that are not distinct. You can place this in a table var or temp table and join against it.
Here is an example using a sub-query:
This returns:
And another method that users a temp table and join:
Also returns: