0
SELECT sum(st.stock_in) - sum(st.stock_out) as'stock_qty',
p.product_name,p.product_limit
FROM stock as st
join products as p
on p.product_id=st.product_id
where 'stock_qty' < 'p.product_limit'
GROUP BY st.product_id
我有两个表产品和股票。我可以在where子句中使用别名吗?
产品表:PRODUCT_ID,PRODUCT_NAME和Product_limit
库存:STOCK_ID,PRODUCT_ID,stock_in,stock_out
从上面的查询,我得到的所有记录,但我想只有那些记录谁的产品极限达到或低于。
如果产品1有50个product_limit并且库存达到了50个限制或低于50个,那么请将这些记录提供给我。
建议我最好的解决方案。
感谢它为我工作 –