select
pppp.pens_product_id,
count(*) as cnt,
string_agg(pppp.param_pl_id::text, ', ' order by pppp.param_pl_id) as param_ids
from prod_line.pens_product_param_pl pppp
where pppp.param_pl_id in (338, 385)
group by pppp.pens_product_id
having count(*) > 1
order by pppp.pens_product_id;