zoukankan      html  css  js  c++  java
  • 更新订单表里面的快递运费

        主要是针对那些一张订单有几条记录的信息,先前寸的EMSGold都是总的,现在想把它更新为按其礼品金币值占比分配快递费用,具体脚本如下:

    select ID,MAX(SEQ_NO) as MA,COUNT(ID) as T
    into #temp001
    from dbo.Fact_Order_Gift
    where EMSPayGold >0
    group by ID having COUNT(ID)>=2 --找出有多条记录的信息

    --#temp002主要是为了后面算最大SEQ_NO的快递费用做铺垫

    select ID,SUM(round(EMSPayGold*((GiftGold*GiftNum)*1.0/PayGold),0)) as PartGold
    into #temp002
    from dbo.Fact_Order_Gift
    where ID in (select ID from #temp001)
    and SEQ_NO not in (select MA from #temp001)
    group by ID

    update dbo.Fact_Order_Gift
    set EMSPayGold=case
    when a.SEQ_NO<b.MA then Round(a.EMSPayGold*((a.GiftGold*a.GiftNum)*1.0/a.PayGold),0)
    when a.SEQ_NO=b.MA then a.EMSPayGold-c.PartGold end
    from dbo.Fact_Order_Gift A,#temp001 B,#temp002 c
    where a.ID=b.ID and a.ID=c.ID

    脚本本身很简单,只是做个记录,以后说不定还要用。

  • 相关阅读:
    WPF基础篇之控件模板(ControlTemplate)
    WPF基础篇之移动特效
    WPF基础篇之空间布局
    00-API-Mongoose
    00-API-Vue
    博客园皮肤设置
    15-Node
    16-Vue-A
    15-MongoDB
    14-电商项目
  • 原文地址:https://www.cnblogs.com/arnold/p/2307689.html
Copyright © 2011-2022 走看看