I've a sample table"
A | 2
A | 0
A | 0
B | 1
B | 1
C | 2
C | 1
And I want Result to be:
A | 2
A | 0
A | 0
C | 2
C | 1
i.e, I don't want the row which has same value in column two
I've a sample table"
A | 2
A | 0
A | 0
B | 1
B | 1
C | 2
C | 1
And I want Result to be:
A | 2
A | 0
A | 0
C | 2
C | 1
i.e, I don't want the row which has same value in column two
Assuming your table has columns 'ch' for the character and 'value' for the number you can do following:
select t.ch, t.value
from test t
join (
select ch, count(distinct value) as 'dst'
from test
group by ch
having count(distinct value)=1
) as q on t.ch!=q.ch;
the subsuquery finds the ch's which only have one distinct value. Those are not included in the join.
Not the most effective query but I guess you want something like this :
SELECT * FROM test WHERE C1 NOT IN (
SELECT C1 FROM test
GROUP BY C1 HAVING COUNT(DISTINCT(C2)) = 1
);
I assume that you don't want the records with only 1 column one example; well if you do :
(for example if there is a "D | 1" row and you want that)
SELECT * FROM test WHERE C1 NOT IN (
SELECT C1 FROM test
GROUP BY C1 HAVING COUNT(DISTINCT(C2)) = 1 AND COUNT(C2) > 1
);
Edit : Here is the sqlfiddle link