Skip to content
Advertisement

Sql – Query to calculate no. of buyers monthly

i would really need your help in creating a query where i can show the number of buyers who made more than 1 order in a month for the period January 2017 to December 2017.

Also, the no. of these buyers that didn’t order again within the next 12 months.

Below is sample my data.

Date CID (customer id) OrderNo
2017-02-03 0:23 924832 000023149
2017-02-05 0:11 924162 000092384
2017-07-01 0:53 914861 000023182
2017-08-09 0:42 924832 000021219

Output should be like this

Month Buyers with >1 order Buyers that didnt order for the next 12M
2017-01-01 122 92
2017-02-01 74 24
2017-03-01 216 107

Advertisement

Answer

This should to match your description:

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