WITH x AS ( SELECT version, oseas, customer, biggroup, sum(sales_usd), sum(pounds), string_agg(distinct mold,', ') FROM b left outer join rlarp.molds m ON m.stlc = b.mold WHERE oseas = 2024 GROUP BY version, oseas, customer, biggroup ) SELECT * FROM X