年初到8月底的经营分析
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
本文转自 qvodnet 51CTO博客,原文链接:http://blog.51cto.com/bks2015/1690677