标题:库存统计
取消只看楼主
copy462829
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2007-1-31
 问题点数:0 回复次数:0 
库存统计
select DISTINCT convert(nvarchar(10),datepart(yy,a.ddate))+'-'+convert(nvarchar(10),
datepart(mm,a.ddate)) as 时间, as 仓库名称 ,(select isnull(sum(f.sl),0)
 from m_kc as f

) as 库存合计 , (select isnull(sum(g.number),0) from m_stockcontent
as g where g.oddtype=1 and g.ddate>='2007-04-26' and g.ddate<='2008-07-27' ) as 进货数量,
(select isnull(sum(k.ypay),0) from m_stockdj as k where k.oddtype=1 and
k.ddate>='2007-04-26' and k.ddate<='2008-07-27') as 进货总金额,
(select isnull(sum(g.number),0) from m_stockcontent as g where g.oddtype=2 and
 g.ddate>='2007-04-26' and g.ddate<='2008-07-27' ) as 退货数量,
(select isnull(sum(k.ypay),0) from m_stockdj as k where k.oddtype=2 and
 k.ddate>='2007-04-26' and k.ddate<='2008-07-27') as 退货总金额,
(select isnull(sum(l.number),0) from m_sellcontent as l where l.oddtype=3 or
l.oddtype=5 and l.ddate>='2007-04-26' and l.ddate<='2008-07-27') as 销售数量,
(select isnull(sum(u.amount),0) from m_sellcontent as u where u.oddtype=3 or u.oddtype=5
 and u.ddate>='2007-04-26' and u.ddate<='2008-07-27') as 销售总金额,
(select isnull(sum(j.number),0) from m_sellcontent as j where j.oddtype=4 or
j.oddtype=6 and j.ddate>='2007-04-26' and j.ddate<='2008-07-27') as 销售退货数量,
(select isnull(sum(u.amount),0) from m_sellcontent as u where u.oddtype=4 or u.oddtype=6 and
 u.ddate>='2007-04-26' and u.ddate<='2008-07-27') as 销售退货总金额 ,
(select isnull(sum(j.number),0) from m_sellcontent as j where j.oddtype=7 and
 j.ddate>='2007-04-26' and j.ddate<='2008-07-27') as 报损数量,
(select isnull(sum(u.amount),0) from m_sellcontent as u where u.oddtype=7 and
u.ddate>='2007-04-26' and u.ddate<='2008-07-27') as 报损总金额,
( (select isnull(sum(u.amount),0) from m_sellcontent as u where u.oddtype=3 or
u.oddtype=5 and u.ddate>='2007-04-26' and u.ddate<='2008-07-27' )-
(select isnull(sum(u.amount),0) from m_sellcontent as u where u.oddtype=4 or
u.oddtype=6 and u.ddate>='2007-04-26' and u.ddate<='2008-07-27')-
(select isnull(sum(u.amount),0) from m_sellcontent as u where u.oddtype=7 and
u.ddate>='2007-04-26' and u.ddate<='2008-07-27')- (select isnull(sum(l.number*u.stockprice),0)
from m_sellcontent as l join m_sp as u on u.id=l.spid where l.oddtype=3 or l.oddtype=5 and
l.ddate>='2007-04-26' and l.ddate<='2008-07-27') ) as 销售利润

from m_stockcontent as a
join m_ck as b on b.id=a.cid where a.ddate>='2007-04-26' and a.ddate<='2008-07-27'
group by datepart(yy,a.ddate) ,datepart(mm,a.ddate), order by 时间 desc


结果
2008-5    主仓库    2163    2010    153658.59    34    4916.8911    513    16190.3153    187    7324.4995    0    0.00    -14801.6119
2008-4    主仓库    2163    2010    153658.59    34    4916.8911    513    16190.3153    187    7324.4995    0    0.00    -14801.6119

我想显示每个月的数量 ····郁闷了  请高手 指点一下
搜索更多相关主题的帖子: 库存 统计 
2008-04-26 12:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-211210-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.132386 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved