create table table_a (a varchar2(10));
insert into table_a
values('中国');
insert into table_a
values('中国');
insert into table_a
values('美国');
insert into table_a
values('美国');
select a, dense_rank() over(order by a) px from table_a
create table table_a (a varchar2(10));
insert into table_a
values('中国');
insert into table_a
values('中国');
insert into table_a
values('美国');
insert into table_a
values('美国');
select a,case a when '中国' then 1
when '美国' then 2 else 0 end as id from table_a
[/Quote]
你只适用于两种数据
用row_number() over
这个分析函数可以实现
select khbh,row_number() over(order by khbh desc)
from a
create table table_a (a varchar2(10));
insert into table_a
values('中国');
insert into table_a
values('中国');
insert into table_a
values('美国');
insert into table_a
values('美国');
select a,case a when '中国' then 1
when '美国' then 2 else 0 end as id from table_a