TSQL -- find records in table with multiples in one column, and at least one specific occurrence of a value in another column
If I have: ourDB.dbo.ourTable with col1 and col2 and col 3
I want to find occurrences such that * A value of col1 occurs multiple times * at least one instance of col2 = 'Val1' at least once.
TSQL -- find specific occurrence in table
So one would start with:
Select col1, col2, col3
FROM ourDB.dbo.ourTable
having count(col1) > 1
WHERE
(col2 = 'Val1')
Group by col1, col2, col3
Order by col1, col2, col3
This would find where col2 always occurs with 'Val1', but how is this generalized to Col2 having 'Val1' at least once ?