select b.spbh,b.spmch,b.shpgg,b.dw,b.shengccj,b.shpchd,sum(case when yue=‘1‘ then a.shqjzhje else 0 end) as 上期结转金额,sum(a.bqxsshl) 本期销售数量,sum(a.bqxscbje) 本期销售成本金额,sum(a.bqxscbje)/8 as 合理周转,sum(case when yue=‘8‘ then a.bqye else 0 end) as 本期余额,c.chbdj as 成本单价
from ymjzhk a,spkfk b,spkfjc c
where a.spid=b.spid and b.spid=c.spid
and a.yue in (‘8‘,‘7‘,‘6‘,‘5‘,‘4‘,‘3‘,‘2‘,‘1‘)
and a.nian=‘2015‘
group by b.spbh,b.spmch,b.shpgg,b.dw,b.shengccj,b.shpchd,c.chbdj
order by b.spbh
时间: 2024-10-02 05:02:41