update 库存 a set 库存数量=(case when a.库存数量-b.计划数量>=0 then a.库存数量-b.计划数量 else 0 end),库存金额=( case when a.库存金额-b.计划金额>=0 then a.库存金额-b.计划金额 else 0 end) from 计划 b where a.物品名称=b.物品名称
解决方案 »
- 要如何学好sql
- 一个select语句,要求去第11条到第15条数据,怎么写?
- 请问怎样判断数据库中的某个表单是否存在 ?
- 查询分析器建立一张表后,紧接着在对象浏览器打开此表,为什么表是只读的?
- sql server 取有效数字
- 关于排序的问题
- 求简单语句,在线等待
- 我自己编了个程序,用ADO连接数据库的,运行的时候没有错,但是到里面的操作时就会出现错误,不知道是什么原因,希望哪位高手能帮我解决下,谢谢!!!
- 百分请教一个mssql连接mysql编码问题
- 存儲過程建立表的問題﹗為什么通過參數指定要建立的表名無效﹗
- 这里没有人关心Yokun吗?还是大家都在闭门造车?
- 交流一下,你们都常去哪个技术网站?
from 计划 a where 库存.物品名称=a.物品名称 and 库存.类别=a.类别
set
库存数量=case when 库存数量-a.计划数量>=0 then 库存数量-a.计划数量 else 0 end,
库存金额=case when 库存金额-a.计划金额>=0 then 库存金额-a.计划金额 else 0 end
from 计划 a, 库存 b
where b.物品名称=a.物品名称 and b.类别=a.类别
update a set a.库存数量=case when a.库存数量-b.计划数量>=0 then a.库存数量-b.计划数量 else 0 end,a.库存金额=case when a.库存金额-b.计划金额>=0 then a.库存金额-b.计划金额 else 0 end
from 库存a, 计划 b where a.物品名称=b.物品名称 and a.类别=b.类别
, 库存金额=case when 库存.库存金额-计划.计划金额>0 then 库存.库存金额-计划.计划金额 else 0 end
from 计划 where 库存.物品名称=计划.物品名称 and 库存.类别=计划.类别
, 库存金额=case when 库存.库存金额-计划.计划金额>0 then 库存.库存金额-计划.计划金额 else 0 end
from 计划 where 库存.物品名称=计划.物品名称 and 库存.类别=计划.类别
, 库存金额=case when 库存.库存金额-计划.计划金额>=0 then 库存.库存金额-计划.计划金额 else 0 end
from 计划 where 库存.物品名称=计划.物品名称 and 库存.类别=计划.类别