function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vipin  PulinholyVipin Pulinholy 

Query to get all Role which don't have any users assocated with

Hi,

 

I need to get all Role Name which don't have any users assosciated with it.

 

SOQL like this: 

Select u.Name, (Select Id From Users) from UserRole u where Id !=null

 

This is not working. Can any one tell me correct soql for this.

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

select id, name from UserRole where id not in (select UserRoleId from user)

Message Edited by SimonF on 11-05-2009 01:18 PM

All Answers

SuperfellSuperfell

select id, name from UserRole where id not in (select UserRoleId from user)

Message Edited by SimonF on 11-05-2009 01:18 PM
This was selected as the best answer
Vipin  PulinholyVipin Pulinholy
Thank You. That worked.