I'm not sure if what I want to do is possible using a single MySQL query, but I figured it wouldn't hurt to ask. I have three tables involved, listed below with the relevant fields:
users
- user_id
- location_id
orders
- order_id
- user_id
- event_id
events
- event_id
- event_date (unix timestamp)
It's for a system where a user places an order to attend an event at a set date and time. What I need is to get a count of the total # of users, grouped by location, who have attended an event 2 times in the last 90 days.
I'd like to do this in one query if possible. I'm wondering if it's possible to use a combination of COUNT and SUM (IF ...) in the query to count users who have attended twice in the last 90 days.
Any help or ideas would be greatly appreciated. Thanks in advance.