I have a table with a customer ID and a date of order.
What I need is to produce a table/report/summat that tracks customers by month.
So, I need to group the dates by month, and then count the customers who are new (date < dates in this month), customers returning (customer appears with date < date this month) and somehow, customers lost (customer appears with date < date this month but not with date in this month).
It seems that I want to use an !=ALL subquery, but I just can't get my head around how best to do this.
Do I need to do some PL/SQL loop to move through each month? It seems I must be able to do some group by based on a to_char(date,'Mon-YY') or something.
I somehow know that this can't be as difficult as it appears to me at the moment, but I don't seem to be able to get any closer to a solution!
My original table has many columns, but the only ones I am aiming to use in this are:
Date, Customer (which is a number).
I'd really appreciate any pointers anyone could give me.
Fee
The question should be [red]Is it worth trying to do?[/red] not [blue] Can it be done?[/blue]
What I need is to produce a table/report/summat that tracks customers by month.
So, I need to group the dates by month, and then count the customers who are new (date < dates in this month), customers returning (customer appears with date < date this month) and somehow, customers lost (customer appears with date < date this month but not with date in this month).
It seems that I want to use an !=ALL subquery, but I just can't get my head around how best to do this.
Do I need to do some PL/SQL loop to move through each month? It seems I must be able to do some group by based on a to_char(date,'Mon-YY') or something.
I somehow know that this can't be as difficult as it appears to me at the moment, but I don't seem to be able to get any closer to a solution!
My original table has many columns, but the only ones I am aiming to use in this are:
Date, Customer (which is a number).
I'd really appreciate any pointers anyone could give me.
Fee
The question should be [red]Is it worth trying to do?[/red] not [blue] Can it be done?[/blue]