exTab
PK col1 col2 col3
---------------------------------
1 val1 val4 val7 **want to return this row only
2 val1 val4 val8
3 val1 val4 val8
4 val1 val5 val9
5 val2 val5 val9
6 val2 val5 val9
7 val2 val6 val0
8 val3 val6 val0
How do I use SQL (with mySQL) to return just the rows that have multiple of the same value in col1 with multiple of the same value in col2 but with a unique value in col 3?
In the table above (exTab), for instance, val1 occurs 4 times in col1, and for these 4 occurrences val4 occurs 3 times in col2, but for these 3 occurrences val7 occurs only once in col3, so I would want to return this row (row 1). Given the criteria, row 1 would be the only row I would want to return from this table.
I've tried various combinations with group by, having count > 1, distinct, where not exits, and more to no avail. This is my first post, so my apologies if I've done something incorrectly.