SQL
DECLARE @ProductId int = 10
IF NOT EXISTS(SELECT * FROM Products WHERE ProductId = @ProductId)
SELECT 'The product doesn''t exists.'
IF EXISTS(SELECT * FROM Products WHERE ProductId = @ProductId and Quantity > 0)
SELECT 'The product is in stock.'
ElSE
SELECT 'The product is out of stock.'
select * from Products
select *
from Categories C
where not exists(
select *
from Products p
where C.CategoryId = P.CategoryId
and P.Quantity > 0
)