You need to sign in to do that
Don't have an account?
Lukesh Karmore
I received an error
" create SOQL query in apex classes"
here challange is create class AccountUtility
My code is :
public class AccountUtility {
public static void viewAnnualRevenue () {
List<Account> accountsList = [SELECT Name, AnnualRevenue FROM Account];
String acctRev;
for(Account a : accountsList) { acctRev = a.Name + ': ' + a.AnnualRevenue;
system.debug(acctRev);
} } }
I received an error plz help here to clear any one ,
Thank you.
here challange is create class AccountUtility
My code is :
public class AccountUtility {
public static void viewAnnualRevenue () {
List<Account> accountsList = [SELECT Name, AnnualRevenue FROM Account];
String acctRev;
for(Account a : accountsList) { acctRev = a.Name + ': ' + a.AnnualRevenue;
system.debug(acctRev);
} } }
I received an error plz help here to clear any one ,
Thank you.
Please update your code like below.
Please Mark this one as best answer, Kinldy let me know if you are facing any issue.
Regards,
Soundar.
why you use" id after select "
And any other easy method to write this code it seems hard to me
it shows me error
Create class
Name: AccountUtility
Create a method
Name: viewAnnualRevenue
Keywords: public, static, and void
Create a list
Name: accountsList
Create a query and assign the results to a list
Fields: Name and annual revenue (Hint: Use API names, not field names or labels)
Object: Account
Create a for loop that iterates through the query results
Object: Account
List name: accountsList
For each item, concatenate the account name, followed by a colon, followed by the account’s annual revenue: <account name> : <annual revenue>
Store the concatenated string in a variable named acctRev
Print the acctRev variable to the debug log: