I have a list of items in different locations. They may have different suppliers but only one supplier can be marked as primary. Below, each location has two suppliers, only one is primary. I want to show only the items where supplier of 77 is not a primary for ANY location. I would hope to get only items 111-28 and 111-30 since 111-20 has 77 as primary for at least one location.[code="sql"]CREATE TABLE jec_item_sup (item_id varchar(10), location varchar(4), supplier varchar(4), primary_supplier varchar(1))INSERT INTO jec_item_supVALUES ('111-20', 1, 77, 'Y'),('111-20', 1, 100, 'N'),('111-20', 2, 77, 'N'),('111-20', 2, 100, 'Y'),('111-28', 1, 77, 'N'),('111-28', 1, 100, 'Y'),('111-28', 2, 77, 'N'),('111-28', 2, 100, 'Y'),('111-30', 1, 77, 'N'),('111-30', 1, 100, 'Y'),('111-30', 2, 77, 'N'),('111-30', 2, 100, 'Y')[/code]I started with this, but I know it's not correct. I still see item 111-20 because location 2 is N for that supplier. [code="sql"]SELECT j.item_idFROM jec_item_sup jWHERE j.primary_supplier = 'N' AND j.supplier = 77 GROUP BY j.item_id[/code]
↧