简体   繁体   English

在Oracle SQL中获取每一行的计数

[英]Getting count of each row in oracle sql

Consider below table: 考虑下表:

EmpId  EmpType ExpUniId
1       A        234
1       B        453
2       A        454

I want to write a sql query such that I get following data 我想编写一个SQL查询,以便获得以下数据

EmpId  EmpType ExpUniId   Count
1       A        234       2
1       B        453       2
2       A        454       1

Count implies number of rows corresponding to each Emp Id 计数表示与每个Emp ID对应的行数

I am using Oracle Sql. 我正在使用Oracle Sql。

Thanks 谢谢

You are looking for the analytic version of count() : 您正在寻找count()的解析版本:

select t.*,
       count(*) over (partition by EmpId) as Count
from table t;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM