Reputation: 3419
I wanted to group some data and then count the number of rows after the duplicate data has been combined into groups.
data:
idx
7706
7706
1000
want to return total count = 2
select count(*) (
select nb.idx
group by nb.idx
) as test
First thing that came to mind was this.
and then I saw someone do this
select count(*) over() group by nb.idx
I'm not sure I totally understand this second one, but I wanted to try various things and compare the speed of the various methods.
Upvotes: 0
Views: 41
Reputation: 339
Try below query..
select count(*), nb.idx from table_name
group by nb.idx
Upvotes: 0