enter image description hereI want to capture only the 3 productscodes from string_agg since My purpose is to see the any three products which are purchased together.
SELECT DISTINCT "ORDERNUMBER", string_agg( "PRODUCTCODE",',') AS Pro_purchased_together
FROM "Sales_data"
WHERE "STATUS"::varchar= 'Shipped'
GROUP BY "ORDERNUMBER"
ORDER BY 2 DESC