Query with COUNT DISTINCT
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