0
union
select max(r.departcoding) as coding,r.depart as depart,sum(-i.materialAmount) as amount,sum(-i.amount*i.fluctuationPrice) as price from
ReturnGoodsRecord r,ReturnGoodsItem i where r.id = i.returngoodsrecord_id
and r.type = '器械包' $P!{returnGoodsSql} group by r.depart
)endTable group by endTable.depart order by coding asc]]>