[英]Incremental count each GROUP in Oracle SQL
Consider below table : 考虑下表:
IP Address
192.168.1.9
192.168.1.4
192.168.1.4
192.168.1.3
192.168.1.9
I want to write a sql query such that I get following data : 我想编写一个SQL查询,以便获得以下数据:
IP Address Count
192.168.1.3 1
192.168.1.4 2
192.168.1.4 2
192.168.1.9 3
192.168.1.9 3
Use dense_rank()
: 使用dense_rank()
:
select ip_address, dense_rank() over (order by ip_address) as cnt
from t;
SELECT ip_address,
ROW_NUMBER() OVER(PARTITION BY ip_address) AS count
FROM table1;
is what id do id是做什么的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.