I'm facing a problem trying to develop a query for this simple database I've created. It gathers 3 suppliers identified by a code (CODICEFORNITORE) which sells products such as phone or cereals, each one of them identified by another code (CODICEPRODOTTO). What I'm trying to accomplish is to get back the number of suppliers who do not sell any Apple product. The association between the products and its supplier is tracked thanks to a third table called Catalogue (CATALOGO).
I've thought that the best way to do that is by a EQUI JOIN between PRODUCT TABLE and CATALOGUE TABLE, then trying to count the number of Apple products sell by suppliers and then exclude those whose count is less or equal to 0. But I can't succed in creating such a query. I have no problem in counting how many suppliers sell Apple products instead.
Achieving the opposite is quite simple (and I'm sure I could do it even in a easier way):
SELECT COUNT(CODICEFORNITORE) AS NUMERO_FORNITORI_APPLE --- This the number of apple supplier
FROM CATALOGO C JOIN PRODOTTI P ON C.CODICEPRODOTTO = P.CODICEPRODOTTO
GROUP BY CODICEFORNITORE, MARCA
HAVING Marca = 'Apple';
--- this returns 1 as expected ---
What I'm trying to achieve should return '2' based on the following table
Thanks in advance and sorry for poor english