I have a table like this :
Id | Value1 | Value2 1 | x | 2 2 | x | 3 3 | x | 7 4 | y | 3 5 | z | 1 6 | z | 7 7 | c | 5 8 | c | 6 How I can get the 'Value1' that doesn't contain value 7 in column 'Value2'
So, the result should be :
y
c
Thanks.
EDITED
As pointed out by PaulF in the comments below, I may have misunderstood your question. Try something like this instead...
SELECT DISTINCT Value1 FROM MyTable a WHERE NOT EXISTS (SELECT Value1 FROM MyTable b WHERE b.Value1 = a.Value1 AND b.Value2 = 7) NOT IN which should be avoided as such
select val1 from yourtable where val2<>7? Or is that too easy?