注册账号 登录
用友之家-用友软件论坛 返回首页

1844833371的个人空间 https://www.oyonyou.com/?421644 [收藏] [复制] [分享] [RSS]

日志

T3整理现存量语句

已有 122 次阅读2015-8-24 16:46

if exists (select * from tempdb..sysobjects where type='u' and name='forcurrentsyz')
    drop table tempdb..forcurrentsyz
    
    go
    
    select a.cwhcode,a.cinvcode,sum(iquantity) as iquantity, 
    sum(a.iquantity/Inventory.iInvExchRate) as inum
    into tempdb..forcurrentsyz from 
    (
    select cwhcode,cinvcode,iaInquantity as iquantity from ia_subsidiary where cvoutype='34'
    union all
    select cwhcode,cinvcode,( case when brdflag=1 then iquantity else -1*(iquantity) end) as iquantity 
    from rdrecord left join rdrecords on rdrecord.id=rdrecords.id 
    ) a left join Inventory
    on a.cinvcode=Inventory.cinvcode
    group by a.cwhcode,a.cinvcode 
    
    go
    
    delete from currentstock
    
    Go
    
    insert into currentstock (cwhcode,cinvcode,iquantity,inum) select cwhcode,cinvcode,iquantity,inum from tempdb..forcurrentsyz
    
    go


路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册账号

QQ|站长微信|Archiver|手机版|小黑屋|用友之家 ( 蜀ICP备07505338号|51072502110008 )

GMT+8, 2024-6-1 04:31 , Processed in 0.022274 second(s), 12 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

返回顶部