分组序号问题
本帖最后由 baopeng82 于 2013-11-04 09:55:41 编辑 我想实现相同的clcode、clph 的序号一样
如下例子:
create table #b1(cjdw char(12),yscode char(12),ysph char(12),clcode char(12),clph char(10),id int)
insert into #b1(cjdw,yscode,ysph,clcode,clph) values('000000016952','204100500766','13072+PB','207061800610','X322')
insert into #b1(cjdw,yscode,ysph,clcode,clph) values('000000016952','204100500766','13072-1+PB','207061800610','X322')
insert into #b1(cjdw,yscode,ysph,clcode,clph) values('000000016952','204100500766','13072塑料+PB','207061800610','C222')
00000001695220410050076613072+PB 207061800610X322 1
00000001695220410050076613072-1+PB 207061800610X322 1
00000001695220410050076613072??+PB 207061800610C222 2
[解决办法]
select *,DENSE_RANK() over( order by clph desc) as no from #b1
/*
00000001695220410050076613072+PB 207061800610X322 NULL1
00000001695220410050076613072-1+PB 207061800610X322 NULL1
00000001695220410050076613072塑料+PB207061800610C222 NULL2*/