A 20150101
A 20150301
A 20151001
B 20140801
B 20141001
B 20151001
---------------
写个SQL 把A, B 的最小时间改成20000101
先谢谢了 大侠们!
------解决思路----------------------
create table test (name varchar(10) , rq varchar(10))
go
insert into test values
('A','20150101'),
('A','20150301'),
('A','20151001'),
('B','20140801'),
('B','20141001'),
('B','20151001')
go
select * from test
go
with mt as (
select row_number() over(partition by name order by rq ) rn ,*
from test
)
update mt set rq = '20000101' where rn =1
go
select * from test
go
drop table test
go
(6 行受影响)
name rq
---------- ----------
A 20150101
A 20150301
A 20151001
B 20140801
B 20141001
B 20151001
(6 行受影响)
(2 行受影响)
name rq
---------- ----------
A 20000101
A 20150301
A 20151001
B 20000101
B 20141001
B 20151001
(6 行受影响)