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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Query with COUNT DISTINCT

odabovalFeb 13 2008 — edited Mar 6 2008
Hello,

We are in 10g ...
I have to compute COUNT DISTINCT of customers, per month, and YearToDate.

Per month, I think I found it out ...
On the year to date ... I have no clue at all ... and I hope that you could provide me with a solution or advice...

Here is my example :
month cust
200711 A
200711 B
200712 A
200712 C
200801 A
200801 B
200802 A
200802 C
200803 A
200803 C
200803 A
200804 D

I would like to get this :
month cust_count cust_count_YTD
200711......2................2 (because cust A and B)
200712......2................3 (because cust A and C)
200801......2................2 (Back to 0 at the beginning of each year)
200802......2................3 (because cust A and C)
200803......2................3 (because cust A and C, and A but count distinct)
200804......1................4 (because D)

Thank you in advance,
Olivier

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 20 2008
Added on Feb 13 2008
5 comments
190,062 views