| Group_No | Id | Status |
|---|---|---|
| 1 | 101 | Active |
| 1 | 102 | Active |
| 2 | 201 | Active |
| 2 | 202 | Approved |
| 2 | 203 | Active |
| 3 | 301 | Inactive |
| 3 | 302 | Active |
| 4 | 401 | Denied |
| 4 | 402 | Denied |
I have to select the groups which all Ids have either 'Active' OR 'Approved' value in Status column. I tried below query.
select group_no
from <table>
where status in ('Active','Approved')
group by group_no
having(count(distinct status)) = 1;
The desired output should be groups 1 and 2. But I am facing problem since 'Active' and 'Approved' are distinct but they are to be considered as same for my purpose. Please suggest how to achieve desired output.