Skip to content
Advertisement

Counting the number of repeating customer and new customer for every month in sql

I have table Order looks like this:

I would like to count the number of repeated customer and new customer with the sales amount for every month of the year. If possible, a table looks like this:

I have tried but I still unable to calculate the sales of each repeated customer and new customer. Plus with the code that I use below, I didn’t get the correct count for each repeated customer and new customer for each month. Is there a sophiscated way to do so?

which give me this output:

Advertisement

Answer

Try this below script-

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement