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
Rupal SinghRupal Singh 

Hi, How can we fetch the account which are related to particular profile through SOQL Query?

Best Answer chosen by Rupal Singh
CharuDuttCharuDutt
Hii Rupal
Try Below Query
SELECT Id,End_Date__c, AccountId  FROM Opportunity WHERE AccountId IN:: setOfAccountId AND Account.Owner.Profile.Name = 'Profile Name'
Please Mark It As Best Answer If It Helps
Thank You!

All Answers

CharuDuttCharuDutt
Hii Rupal Singh
Try Below Query
SELECT Id, Type, Name, Owner.Profile.name FROM Account where Owner.Profile.name = 'Profile Name'
Please Mark It As Best Answer If It Helps
Thank You!
ravi soniravi soni
hi Rupal,
try below query and fatch account of praticular profile.
SELECT Id, Name FROM Account where Owner.Profile.name ='profile Name'

use above query and let me know if it helps you by marking it as best answer.
Thank you
Rupal SinghRupal Singh
Thank you @veer soni and @CharuDutt.
Rupal SinghRupal Singh
Hello, Here is the soql where I am fetching End Date from opportunity but now I have to fetch the record with the particular profile user of account related to the opportunity. 
SELECT Id,End_Date__c, AccountId  FROM Opportunity WHERE AccountId IN: setOfAccountId
CharuDuttCharuDutt
Hii Rupal
Try Below Query
SELECT Id,End_Date__c, AccountId  FROM Opportunity WHERE AccountId IN:: setOfAccountId AND Account.Owner.Profile.Name = 'Profile Name'
Please Mark It As Best Answer If It Helps
Thank You!
This was selected as the best answer