34,593
社区成员
发帖
与我相关
我的任务
分享
SELECT t.theTypeName, a.calNum,b.supplyPermoney
FROM typetable t LEFT OUTER JOIN
(SELECT theTypeName, SUM(goodsnum) AS calNum
FROM ruhuo
WHERE operation = '入货' AND supplyPermoney > 0
GROUP BY theTypeName) a
ON t.theTypeName = a.theTypeName
left outer join
(select top 1 R.theTypeName,R.supplyPermoney from ruhuo R,typetable T1 where R.theTypeName=t1.theTypeName and R.operation = '入货' AND R.supplyPermoney > 0 order by R.id desc) b on
b.theTypeName=t.theTypeName