壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2071|回复: 11

[天心ERP] 谁能帮我分析一下该语句

[复制链接]
发表于 2007/11/10 14:50:36 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622  。

您需要 登录 才可以下载或查看,没有帐号?注册

x
select c.cus_no,e.name, isnull(c.bzscs,0)+isnull(d.zscs,0) as zcs ,isnull(c.bzscs,0)as bzscs,
isnull(d.zscs,0) as zscs,convert(decimal(18,4),(convert(decimal(18,6),c.bzscs)/(c.bzscs+d.zscs))) as zsl
from
(select count(*) as bzscs,b.cus_no
    from (select b.qty - sum(isnull(a.qty,0)) as qty,a.os_no ,a.prd_no ,b.os_dd
           from tf_pss a,tf_pos b
           where a.os_no=b.os_no and a.prd_no=b.prd_no and a.ps_dd< b.est_dd
           group by a.os_no ,a.prd_no,b.qty ,b.os_dd
        ) a, mf_pos b
        where a.os_no=b.os_no and a.qty>0
        group by b.cus_no
) c,

(select count(*) as zscs,b.cus_no
    from (select b.qty - sum(isnull(a.qty,0)) as qty,a.os_no ,a.prd_no ,b.os_dd
           from tf_pss a,tf_pos b
           where a.os_no=b.os_no and a.prd_no=b.prd_no and a.ps_dd< b.est_dd
           group by a.os_no ,a.prd_no,b.qty ,b.os_dd
           ) a, mf_pos b
    where a.os_no=b.os_no and a.qty<=0
    group by b.cus_no
) d,cust e
where c.cus_no=d.cus_no and c.cus_no=e.cus_no
我看起来有点费劲,谁能分析一下
 楼主| 发表于 2007/11/10 14:50:49 | 显示全部楼层
select c.cus_no,e.name, isnull(c.bzscs,0)+isnull(d.zscs,0) as zcs ,isnull(c.bzscs,0)as bzscs,
isnull(d.zscs,0) as zscs,convert(decimal(18,4),(convert(decimal(18,6),c.bzscs)/(c.bzscs+d.zscs))) as zsl
from
(select count(*) as bzscs,b.cus_no
    from (select b.qty - sum(isnull(a.qty,0)) as qty,a.os_no ,a.prd_no ,b.os_dd
           from tf_pss a,tf_pos b
           where a.os_no=b.os_no and a.prd_no=b.prd_no and a.ps_dd< b.est_dd
           group by a.os_no ,a.prd_no,b.qty ,b.os_dd
        ) a, mf_pos b
        where a.os_no=b.os_no and a.qty>0
        group by b.cus_no
) c,

(select count(*) as zscs,b.cus_no
    from (select b.qty - sum(isnull(a.qty,0)) as qty,a.os_no ,a.prd_no ,b.os_dd
           from tf_pss a,tf_pos b
           where a.os_no=b.os_no and a.prd_no=b.prd_no and a.ps_dd< b.est_dd
           group by a.os_no ,a.prd_no,b.qty ,b.os_dd
           ) a, mf_pos b
    where a.os_no=b.os_no and a.qty<=0
    group by b.cus_no
) d,cust e
where c.cus_no=d.cus_no and c.cus_no=e.cus_no
 楼主| 发表于 2007/11/10 14:51:01 | 显示全部楼层
怎么是联在一起的啊
发表于 2007/11/12 11:54:38 | 显示全部楼层

回复楼主

回复楼主:
       请在sql查询分析器中把语举分段分条件断行就很清楚啦,关键就是a.b.c.d.e表是由嵌套查询的结果集做为关联表.附图:
      
sql query.JPG
 楼主| 发表于 2007/11/12 16:13:42 | 显示全部楼层
问题是什么意思,起到什么效果
发表于 2007/11/12 18:26:49 | 显示全部楼层
看别人的还不如自已写
发表于 2007/11/12 18:37:26 | 显示全部楼层
密密麻麻,看起来累呀
发表于 2007/11/12 19:44:22 | 显示全部楼层
这个语句是抓对一个客户的到交货期仍未进货/销货的量以及到交货期已经超进货或销货的量

比如一个客户下了两个订单,一个要A产品100个,一个要B产品20个,如果销货是第一个按交货期销了95个,第二个按期超销了3个

则结果是 客户代号,客户名称,5+(-3)=2  zcs,5 bzscs,-3 zscs,5/2=2.5  zsl
发表于 2010/7/15 15:48:55 | 显示全部楼层
精!!!!!
发表于 2012/1/4 10:08:04 | 显示全部楼层
{:soso_e113:}
发表于 2013/1/10 01:18:40 | 显示全部楼层
{:soso_e179:}{:soso_e179:}
发表于 2013/6/7 09:42:42 | 显示全部楼层
很强悍,,看不懂!!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/29 07:02 , Processed in 0.020625 second(s), 17 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表