0

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

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

I am using Oracle Sql.

Thanks

1 Answer 1

5

You are looking for the analytic version of count():

select t.*,
       count(*) over (partition by EmpId) as Count
from table t;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.