I want to make a simple view that allows the to see if the sum of stock from different warehouses are >0 and < that the minimum stock of said product.
Here is the code:
SELECT a.code, a.description, a.stk_min , b.Stk_Qty
FROM a
INNER JOIN b ON a.code = b.productcode
WHERE a.stk_min > 0 and
(SELECT SUM(b.Stk_Qty )
FROM b
INNER JOIN a ON a.code = b.productcode
Group By a.code) <= a.stk_min
And of course I get the error
Subquery returned more than 1 value. This is not permitted when the subquery follows
=
,!=
,<
,<=
,>
,>=
or when the subquery is used as an expression.
Is there something I can do to change this?