日期:2014-05-17 浏览次数:20433 次
create table t_order
(
id varchar(10),
name1 varchar(20),
name2 varchar(20),
displayorder varchar(10)
)
1,aaaaaa,______,3
2,bbbbbb,______,1
3,aaaaaa,222222,5
4,bbbbbb,222222,2
5,cccccc,222222,4
6,bbbbbb,333333,0
7,cccccc,______,6
insert into t_order values ('1','aaaaaa','______',3)
insert into t_order values ('2','bbbbbb','______',1)
insert into t_order values ('3','aaaaaa','222222',5)
insert into t_order values ('4','bbbbbb','222222',2)
insert into t_order values ('5','cccccc','222222',4)
insert into t_order values ('6','bbbbbb','333333',0)
insert into t_order values ('7','cccccc','______',6)
update t_order set name2 = '-1' where name2='______'
select RANK() over (partition by name1 order by displayorder,name1,cast(name2 as int)) as order2, * from t_order order by displayorder