SELECT ENTER-RETURN FROM (SELECT CASE WHEN A='进货' THEN B ELSE NULL END AS ENTER ,
CASE WHEN A='退货' THEN B ELSE NULL END AS RETURN FROM (
SELECT SUM(B) AS B,A FROM TABLE_NAME GROUP BY A) P1)P2
由于你给的需求不够完整,所以我就给你一个大致框架,你自己可以进行相应的修改补充
如字段名,表名啥的自己替换一下
select sum(case when a='退货' then -b else b end)
from 表