|
select e.name ,inv.rawno,inv.ppp as 投入价值,outv.sss AS 产出价值, (outv.sss-inv.ppp) as 利润,利润/产出价值*100 AS [利润率%]
from em_data as e,
[SELECT e.name,i.rawno,sum(i.quanity_in*p.pu_price) as ppp
from em_data as e,input as i , pu_price as p
where e.no=i.no and i.rawno=p.rawno and i.code=p.code and i.note_pu=p.note_pu and p.finish=yes
GROUP BY e.name, i.rawno
ORDER BY i.rawno DESC]. as inv,
[SELECT e.name,p.rawno,sum(o.quanity_OUT*sa.sa_PRICE) as sss
from em_data as e,output as o , sa_price as sa , pu_price as p
where e.no=o.no and o.rawno =p.rawno and p.finish=yes and o.code=sa.code
group by e.name,p.rawno
ORDER BY p.rawno DESC]. as outv
where e.name=inv.name and inv.name=outv.name and inv.rawno=outv.rawno
ORDER BY inv.rawno
=================================================+++++++++++++++++++++++++++++++++++
SELECT e.name,i.rawno,sum(i.quanity_in*p.pu_price) as ppp
from em_data as e,input as i , pu_price as p
where e.no=i.no and i.rawno=p.rawno and i.code=p.code and i.note_pu=p.note_pu and p.finish=yes
GROUP BY e.name, i.rawno
ORDER BY i.rawno DESC;
|
|