How to write a SOQL Query in Apex to Fetch the minimum amount of all the related opportunities for an account

I have an account which has related opportunities. For those opportunities I wish to get the minimum amount through a SOQL Query. How can I achieve this if I need to use only 1 SOQL Statement in Apex?

I tried the following:

set<ID> setId = new Set<ID>();
List<Opportunities> oppList = [Select Id, Name, Amount from Opportunity Where Account.Name="Test Account 1"];

for(Opportunity opp: oppList){
setId.add(opp.id);
}

AggregateResult[] grp = [Select MIN(Amount) minAmt from Opportunity Where ID IN: setId];

for(AggregateResult agg: grp){
System.debug('Minimum is' + agg.get('minAmt');
}

I tried something like this but Im unable to convert it into a single SOQL Query.

Read more here: Source link