[SalesForce] System.QueryException: No such column ‘BillingStateCode’ on entity ‘Account’

I have enabled State and Country picklist feature and I am using this query in a web service class:

SELECT BillingStateCode FROM Account

But I am getting:

No such column 'BillingStateCode' on entity 'Account'.

I am using BillingStateCode and BillingCountryCode fields in another class and there it works fine. If I try to execute above query in developer console, there too it works without error. Why does just this one class fail?

Best Answer

If you are getting this error in apex class then I suggest you to update the API Version of your class.

You will get this error if your Apex Class version is less than 27. Update the API version to 27+ and it will compile.