I have a user table with a last_login column.
I have an additional table called group.
There is also a join table group_user
I have the following query:
select count(u.id), group.name
from user u
left join group_user gu where gu.user_id = u.id
left join group g where g.id = gu.group_id
where u.last_login is not null
group by g.name
This generates total users logged in by group.
I then update the query to where u.last_login is null
Which generates total users not logged in.
How would I go about pulling all of the data at once with the following columns:
count(users), count(logged in), count(not logged in), % of total users that have logged in, group name