I am trying to implement a mysql query for some report and can't figure it out.
Let's say we have a 'companies'
table, a 'users'
and a 'company_users'
.
The requested result set is:
'company_name', 'active_users', 'date'
(lets say 30 days back).
So I have to calculate user counts up to date based on users.created_at
.
I could use some help to achieve it without stored procedure because I'll need to join the result set with another table.
Thank you.
Asked
Active
Viewed 74 times
0

Anton
- 540
- 3
- 13
-
1What have you tried so far? And why the rails tag, are you doing this in mysql or activerecord? – Eyeslandic Feb 11 '17 at 23:05
-
The rails tag is my mistake. It is a mysql question. What I did so far is created a 30 dates result set. looped over it and calculated the count of 'active' users up to that date. I already achieved the expected result using a sub query instead of a fancy loop. Thanks. – Anton Feb 12 '17 at 08:54