Reputation: 105
I have the following example data:
id | domain |
---|---|
1 | test |
2 | example |
3 | test |
4 | main |
5 | main |
6 | test |
What I want to do in a Select statement is to end with the following:
id | domain | domain_occurrences |
---|---|---|
1 | test | 3 |
2 | example | 1 |
3 | test | 3 |
4 | main | 2 |
5 | main | 2 |
6 | test | 3 |
How can I do this?
Upvotes: 0
Views: 457
Reputation: 10222
Use count(*) over (partition by domain)
:
select
*,
count(*) over (partition by domain) as domain_occurencies
from mytabel
Upvotes: 3