Home > Database > Mysql Tutorial > Oracle数据库中关于利用查询直接排名的方法

Oracle数据库中关于利用查询直接排名的方法

WBOY
Release: 2016-06-07 17:08:44
Original
1736 people have browsed it

首先,来构造一些数据 drop table test;create table test( name varchar2(10), account number(5)); insert into

首先,,来构造一些数据

drop table test;
create table test
(
       name varchar2(10),
       account number(5)
);

insert into test values ('张三','5');
insert into test values ('王五','10');
insert into test values ('小二','10');
insert into test values ('李四','20');
insert into test values ('小三','40');
insert into test values ('小四','50');
insert into test values ('小五','90');
insert into test values ('小六','90');
insert into test values ('小七','90');
commit;

下面来看一下一些方式的排名结果:

1.  select     t.*,dense_rank() over(order by t.account asc)   排名   from test t;

               

 

2. select   t.*,dense_rank() over(order by t.account desc) 排名    from  test t;

               

 

3. select t.*,rank() over(order by t.account asc) 排名 from test t;

              

 

4. select t.*,rank() over(order by t.account desc) 排名 from test t;

              

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template