SQL lists all rows where column A appears multiple times but has different values for column B
2 answers
Try this query:
SELECT ColumnA
FROM mytable
GROUP BY ColumnA
HAVING COUNT(*) > 1 AND COUNT(DISTINCT ColumnB) = COUNT(*)
- The first predicate in an expression
HAVING
evaluates to true if the valueColumnA
appears more than once. - The second predicate is true if all values in
ColumnB
are different within the groupColumnA
.
0
source to share