mysql - Getting unique users for consecutive days -


i have task find unique users our table cumilative days.

what wanted

select count(distinct(userid))  session_tab  date(session) = '2016-01-15 00:00:00' union select count(distinct(userid))  session_tab  date(session in ('2016-01-15 00:00:00','2016-01-16 00:00:00') union select count(distinct(userid))  session_tab  date(session in ('2016-01-15 00:00:00','2016-01-16 00:00:00','2016-01-16 00:00:00') 

and on...for next 30 days.

can 1 pls let me know how can achieved

to next 30 days, go between curdate() , curdate() plus 30 days. after that, it's case of counting , grouping:

select date(session), count(distinct userid)   session_tab   date(session) between curdate() , date_add(curdate(), interval 30 day)   group date(session)   order date(session); 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -