I attached a simple table with two columns, Item number and Order number. In the example attached only item number C5664 and A9930 met the criteria. How do I write this code in SQL?
Advertisement
Answer
If you group by the item numbers then the unique count for the order numbers will be 1
SELECT "Item Number", MAX("Order Number") AS "Order Number" FROM yourtable AS t GROUP BY "Item Number" HAVING COUNT(DISTINCT "Order Number") = 1