+ Start a Discussion
Arthur Almeida 12Arthur Almeida 12 

how to select 2 rows with same account?

I would like to do a select in one account that has 2 assets with status X

I tried with:
SELECT Id, AccountId FROM Asset WHERE Status = 'X' LIMIT 2

but this return 2 rows with 2 different accounts... I need it to be the same account...

how does it?
Best Answer chosen by Arthur Almeida 12
AnkaiahAnkaiah (Salesforce Developers) 
Hi Arthur,

You can use an aggregate SOQL query for this.
SELECT AccountId , count(Id) FROM Asset WHERE Status = 'X' GROUP BY AccountId HAVING Count(AccountId) > 1
If this helps, Please mark it as best answer.