Skip to content
Advertisement

How many customers made a purchase for the first time at STORE 1 per month?

Hey guys I’m having trouble solving an exercise of SQL: I can’t seem to understand how can I write a query that answers the question in the title based on a purchase database. I tried selecting distinct values per month, but the same customer can make a purchase in different months, so they would end up being duplicated.

Columns of store1.Orders:

  • orderID
  • order_date
  • purchase_status
  • revenue
  • customerID

Columns of store1.Customers:

  • customerID
  • Name
  • e-mail

Could someone help me?

Advertisement

Answer

I’d approach the problem from user, not from order.

There may be typos or syntax errors in the query, I didn’t test it. But you’ll get approach.

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