CREATE TABLE customers
( customer_id number(10) not null,
customer_name varchar2(50) not null
);
INSERT INTO customers VALUES(22,'W');
INSERT INTO customers VALUES(22,'W');
INSERT INTO customers VALUES(20,'Q');
INSERT INTO customers VALUES(20,'Q');
COMMIT;
现在我正在尝试按客户名称获得与我的分区相对应的不同等级
SELECT DENSE_RANK() OVER(PARTITION BY customer_name ORDER BY CUSTOMER_ID) , CUSTOMER_ID FROM CUSTOMERS;
输出:
1 20
1 20
1 22
1 22
预期输出:
1 20
1 20
2 22
2 22