Example queries:
SELECT d.dept_no,
d.dept_name,
COUNT(p.upc) AS numProducts
FROM products AS p
LEFT JOIN departments AS d ON p.department=d.dept_name
WHERE p.upc LIKE '0000000%'
AND d.department < 500
GROUP BY d.dept_no,
d.dept_name
HAVING COUNT(p.upc) <> 0
ORDER BY d.dept_no,
d.dept_name
SELECT
d.dept_no,
d.dept_name,
COUNT(p.upc) AS numProducts
FROM
products AS p
LEFT JOIN departments AS d ON p.department=d.dept_name
WHERE
p.upc LIKE '0000000%'
AND d.department < 500
GROUP BY
d.dept_no,
d.dept_name
HAVING
COUNT(p.upc) <> 0
ORDER BY
d.dept_no,
d.dept_name