update a set 数量=(select isnull(sum(数量),0)+isnull(sum(变量),0) from tb where 产品=a.产品 and id<a.id)
from tb a
where exists(
select * from tb where 产品=a.产品 and id<a.id)
from tb a
where exists(
select * from tb where 产品=a.产品 and id<a.id)
解决方案 »
- 为什么select getdate() as sysdate返回的日期,在不同电脑上格式不同?
- jdbc链接sql2005失败!(初学,希望大家多多指教)
- 一条有难度的sql语句,高手请进
- 请问如何获得某列字符串中某字符左边或右边的字符串,谢谢
- [DBNMPNTW]找不到指定的 SQL Server???
- 100分求经典排序得SQL语句(在线等)
- 基础问题,在线等候
- 怎样在SQL SEVER 7.0 中将图片存储在Image中
- 请教关于报表打印的问题
- 寻找一种思路,例如要统计一个球员在一个赛季的上场时间,赛季包括N多场比赛,请问思路是什么?
- 求当前日期的下个星期五是几号
- 百分求解,高手进来看看!查询表结构信息!
from tb a
where exists(
select * from tb where 产品=a.产品 and( 加入时间>a.加入时间 or 加入时间=a.加入时间 and id<a.id))
from tbl where 产品名=a.产品名
and 加入时间<a.加入时间)+a.加入数量)
from tbl as a