pt | pm
1 | 1
1 | 2
1 | 3
2 | 1
2 | 2
select pt value who has all value of pm(1,2,3) in this table output should be 1.
CodePudding user response:
select count(pm),pt from group by pt having count(pm)=(select count(distinct pm) from <master_table>)
Try using group by, having clause and nested query.
CodePudding user response:
select pt, group_cocate(distinct pm order by pm seperator ',') as pml from table group by pt having pml='1,2,3';