[英]Advice with MySql Formula
select v1.Value1 - v2.Value2
from (Select Amt as Value1
from lineitem
WHERE item ='test1' and type='receiving')
as v1 CROSS JOIN (Select Amt as Value2
from lineitem
WHERE item ='test1' and type='shipping')
as v2;
This script isn't returning anything. 该脚本不返回任何内容。 What I'm trying to do is subtract the Amts on the same table from receiving and shipping.
我想做的是从收货和发货中减去同一张桌子上的Amts。 Any advice?
有什么建议吗?
SELECT sum(case when type='receiving' then amt else -amt end)
FROM lineitem WHERE item='test1' AND type IN ('receiving','shipping')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.