Ver originalselect cod1,count DISTINCT (cod2) valor from tabla3 where cod2 in ('1','2','3')group by cod1 having valor=3