zoukankan      html  css  js  c++  java
  • 同步批次和普通库存


    begin tran
    --
    select sum(q) as stock_q,sum(q * tax_entry_price) as tax_entry_a,sum(q * a.retail_price) as tax_retail_a
    from stk_fifo s,article a
    where s.aid=a.aid

    select sum(stock_q),sum(tax_entry_a) as tax_entry_a,sum(tax_retail_a) as tax_retail_a from article_storespace


    update article_storespace
    set article_storespace.stock_q=b.stock_q,
    article_storespace.tax_entry_a=b.tax_entry_a,
    article_storespace.tax_retail_a=b.tax_retail_a,
    article_storespace.tax_avgentry_price=b.tax_avgentry_price
    from
    (
    select store_id,s.aid,sum(q) as stock_q,sum(q * tax_entry_price) as tax_entry_a,sum(q * a.retail_price) as tax_retail_a,
    sum(q * tax_entry_price)/sum(q) as tax_avgentry_price
    from stk_fifo s,article a
    where s.aid=a.aid
    group by store_id,s.aid
    having sum(q) <>0
    )b
    where article_storespace.storespace_id=b.store_id and article_storespace.aid=b.aid

    select sum(q) as stock_q,sum(q * tax_entry_price) as tax_entry_a,sum(q * a.retail_price) as tax_retail_a
    from stk_fifo s,article a
    where s.aid=a.aid

    select sum(stock_q),sum(tax_entry_a) as tax_entry_a,sum(tax_retail_a) as tax_retail_a from article_storespace

    commit

  • 相关阅读:
    最近写代码的风格,请帮忙分析下优缺点
    jQuery的回调管理机制(三)
    jQuery的回调管理机制(二)
    jQuery的回调管理机制
    iOS组件化
    iOS内存泄漏检测及分析
    iOS 路由
    iOS https抓包工作记录
    第二章 算法入门
    第一章 算法在计算中的作用
  • 原文地址:https://www.cnblogs.com/kuailewangzi1212/p/3154955.html
Copyright © 2011-2022 走看看