Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Partition by clause is counting one extra.

syed haiderApr 20 2018 — edited Apr 20 2018

When I use count by using partition by, I get one extra number in my count. Whereas, when I count by using group by clause I get one less. Why is that?

Thanks in advance.

Partition by query;

Select distinct market_location,

count(distinct case when upper(source_method) = 'abc' and upper(source_name) ='AIM' then client_number else 0 end) over (partition by market_location)

from table1

result = 56

Group by query;

SELECT market_location, count(distinct client_number)

from table1

where upper(source_name) = 'AIM'

and upper(source_method) = 'abc'

by market_location

result = 55

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 18 2018
Added on Apr 20 2018
7 comments
338 views