I need to run a query that does a very simple thing but I am unable to figure out the best way to do it.
I only want to get results that have an inventory count of more than zero. The below query comes with nothing returned for some reason. If I placed a GROUP BY, it will give me all of the records when all I need is just a count for now.
SELECT COUNT(*), IFNULL((SELECT SUM(quantity) FROM inventory i WHERE p.id = i.product_id), 0) AS quantity
FROM products p WHERE p.available = '1' HAVING quantity > 0 ORDER BY quantity DESC;
Thanks for your help.