大家好,
我有一个问题:
有一个表有三个列:
书名 价格 日期
a 1.5 2009.11.1
a 1.3 2009.11.2
a 1.1 2009.11.4
b 3.5 2009.11.1
b 3 2009.11.3
c 10 2009.11.2
c 8 2009.11.5 书按照日期不同的价格,当然以最新的日期的价格生效
那么,我如何找出以上的最新的日期的所有书的价格,及对该价格统一下降10% 查询是:select 书名,
价格*0.9,
日期
from tb t
where not exists(select 1 from tb where 书名=t.书名 and 日期>t.日期)
但是我要的是直接对表进行update
应该用什么处理
谢谢
我有一个问题:
有一个表有三个列:
书名 价格 日期
a 1.5 2009.11.1
a 1.3 2009.11.2
a 1.1 2009.11.4
b 3.5 2009.11.1
b 3 2009.11.3
c 10 2009.11.2
c 8 2009.11.5 书按照日期不同的价格,当然以最新的日期的价格生效
那么,我如何找出以上的最新的日期的所有书的价格,及对该价格统一下降10% 查询是:select 书名,
价格*0.9,
日期
from tb t
where not exists(select 1 from tb where 书名=t.书名 and 日期>t.日期)
但是我要的是直接对表进行update
应该用什么处理
谢谢
set t.价格=t.价格*0.9
from tb t
where not exists(select 1 from tb where 书名=t.书名 and 日期>t.日期)
t
set
t.价格=t.价格*0.9
from
tb t
where
not exists(select 1 from tb where 书名=t.书名 and 日期>t.日期)