实例:
初始化数据
create table employee (empid int ,deptid int ,salary decimal(10,2))
insert into employee values(1,10,5500.00)
insert into employee values(2,10,4500.00)
insert into employee values(3,20,1900.00)
insert into employee values(4,20,4800.00)
insert into employee values(5,40,6500.00)
insert into employee values(6,40,14500.00)
insert into employee values(7,40,44500.00)
insert into employee values(8,50,6500.00)
insert into employee values(9,50,7500.00)
select deptid,salary, row_number() OVER (PARTITION BY deptid ORDER BY salary) from employee
数据显示为:
"DEPTID" ,"SALARY", "ROW_NUMBER()OVER(PARTITIONBYDE"
"10", "4500.00", "1"
"10", "5500.00", "2"
"20", "1900.00", "1"
"20", "4800.00", "2"
"40", "6500.00", "1"
"40", "14500.00", "2"
"40", "44500.00", "3"
"50", "6500.00", "1"
"50", "7500.00", "2"