Just a practical problem, a bit confusing, I would appreciate it if anyone could clarify this.
I have a DB called Product and the other is PC. I am trying to fulfill the query "find the average size of the PC hard drive for all those manufacturers who also make printers"
Here is my code:
SELECT maker, AVG(hd) FROM pc, product WHERE pc.model=product.model GROUP BY maker HAVING COUNT(type='PR')>=1
type is the Product attribute, which is designed for either a laptop computer (PR) or a PC, however, only manufacturers who produce printers are not shown in the HAVING statement, instead I return the AVG for each manufacturer to the Product Table.
UPDATE
Here's what the relationship looks like:
Product(maker, model, type) PC(model, hd, speed, ram, price) Printer(model, color, type, price)
source share