| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 838 人关注过本帖
标题:库存统计
只看楼主 加入收藏
copy462829
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2007-1-31
收藏
 问题点数:0 回复次数:1 
库存统计
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
happynight
Rank: 8Rank: 8
等 级:贵宾
威 望:15
帖 子:807
专家分:760
注 册:2008-4-26
收藏
得分:0 
呵呵 你搜索下交叉表 应该能实现你的要求
给个地址你
http://www.

[[it] 本帖最后由 happynight 于 2008-4-28 09:46 编辑 [/it]]
2008-04-28 09:16
快速回复:库存统计
数据加载中...
 
   



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

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