sql - Get column with two two rows having specific values -
i have table looks this:
| col1 | col2 | |------|------| | | 1 | | | 2 | | | 3 | | b | 1 | | b | 3 | | c | 1 | | c | 2 |
i need find value of col1
2 rows same col1
value exist has col2 value of 1 , 2
results be:
| col1 | |------| | | | c |
you can filter rows col2
values want, group col1
, take groups count = 2
select col1 yourtable col2 in (1, 2) group col1 having count(distinct col2) = 2
Comments
Post a Comment