日期:2014-05-18 浏览次数:20569 次
select * from (select a.orderno, sum(isnull(a.inqty,0)) as inqty,sum(isnull(a.outqty,0)) as outqty, sum(isnull(a.runqty,0)) as runqty,a.unit,a.price,a.curr, sum(isnull(a.runqty,0))*a.price as priceamnt,SUM(runBoxqty) AS boxqty from view_goodsrunpart a where (1=1) group by a.orderno)aa where runqty>0 order by orderno,isbn
------解决方案--------------------
select a.orderno, sum(isnull(a.inqty,0)) as inqty,sum(isnull(a.outqty,0)) as outqty, sum(isnull(a.runqty,0)) as runqty,a.unit,a.price,a.curr, sum(isnull(a.runqty,0))*a.price as priceamnt,SUM(runBoxqty) AS boxqty from view_goodsrunpart a group by a.orderno order by a.orderno having sum(isnull(a.runqty,0))>0