Skip to content
Advertisement

MySQL, Determine number of customer doing first transaction on certain store

I have transaction table as below

“I want number of newly registred customer who did their first transaction on Store1 during July 01 – July 30”

In this case the expected result is 1 which is CustomerID B with OrderID 4

How to query out the data with using EXISTS / NOT EXISTS, but not using IN / NOT IN?

This is what I got so far but I don’t want to use NOT IN for solution

Moreover since the date is parameterized, the where clause on date should be the same. Above solution the date parameter is not exactly the same, as first I’m using between and in subquery I’m using date less than the initial date.

Advertisement

Answer

One approach… with no IN or EXISTS…

Edit: For the alternative (and incorrectly stated) interpretation of your problem, something like this should suffice:

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