I am new to SOQL. How do I fetch the country,state,city of an account?

I have tried this but have an error.

Select AccountNumber,name, BillingAddress.City from Account 

2 Answers 2


Here you can found a list of all SOAP API fields accepted in Account (standard fields)

Account SOAP API

If you need the Billing Address fields you can use:

SELECT Id, Name, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry FROM Account

or with ShippingAddress...

SELECT Id, Name, ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode, ShippingCountry FROM Account

even you can retreive Longitude and Latitude from each one.

Good luck!


are the correct API Names

To check the object's field correct API Name use describe call in developer console and check all fields label Name and corresponding API Name in debug log

for(Schema.SobjectField strFld: Account.SobjectType.getDescribe().fields.getMap().Values())
    system.debug('-----Label Name----'+strFld.getDescribe().getLabel()+'-------API Name--'+strFld.getDescribe().getName());

Select name, BillingCity, BillingCountry, BillingState from Account 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.