You need to sign in to do that
Don't have an account?
Vivekh88
Profile name from LoginHistory using SOQL
Hi,
I have a requirement where i need to get the total count of Logins done by the particular profile.
Profile Month Times Logged in
System Administrator August 2016 150
Standard User August 2016 123
I tried to give this query,
List<Aggregateresult> logquery = [Select count(LoginTime) logintime, userid from LoginHistory where userid =: scope Group by userid];
But this wil execute the total count by Users. But i need it for Profiles. Is there any other workaround to do this?
Thanks
Vivekh
I have a requirement where i need to get the total count of Logins done by the particular profile.
Profile Month Times Logged in
System Administrator August 2016 150
Standard User August 2016 123
I tried to give this query,
List<Aggregateresult> logquery = [Select count(LoginTime) logintime, userid from LoginHistory where userid =: scope Group by userid];
But this wil execute the total count by Users. But i need it for Profiles. Is there any other workaround to do this?
Thanks
Vivekh
The problem with Login History is we cannot traverse to parent object. Instead of this, you can try:
SELECT count(id), Profile.Name FROM User where LastLoginDate <= today group by Profile.Name
This will give you the count of logged in users against the profiles.
Pls mark this answer if it solves your query.
Thanks,
Dilip Singh