Reputation: 4848
I have an oracle view with this structure
--------------------
Column 1 | Column 2|
---------|---------
B | TEST |
--------------------
A | ATEE |
--------------------
B | TEST |
--------------------
A | TEST |
--------------------
C | TEST |
--------------------
I wan to add an new column that hold the total of values of column 1 like this :
--------------------------
Column 1 | Column 2|TOTAL |
---------|---------|------|
B | TEST | 2 |
-------------------|------|
A | ATEE | 2 |
-------------------|------|
B | TEST | 2 |
-------------------|------|
A | TEST | 2 |
-------------------|------|
C | TEST | 1 |
-------------------|------|
How I can do this count ,thanks in advance for any help
Upvotes: 0
Views: 45
Reputation: 1270443
You seem to want the count()
window function:
select t.*, count(*) over (partition by column1) as total
from t;
Upvotes: 3