Reputation: 1093
Can someone help me with a SQL Query that will display all users that have made a post every day for the last 7 days?
My questions table is tblQA and my users are userID and questionID for the post. I want to run a query that helps me know how many active users are using the database every day.
Thanks so much!
Upvotes: 0
Views: 272
Reputation: 1
SELECT user_id
FROM tblQ
where post_date > DATE_SUB(NOW(), INTERVAL 7 DAY))
group by user_id
having COUNT(distinct(post_date)) = 7
Upvotes: 0
Reputation: 70460
SELECT userID
FROM tblQ
WHERE DATEDIFF(NOW(),postdate) < 7
GROUP BY userID
HAVING COUNT(DISTINCT DATE(postdate)) = 7
Upvotes: 1